Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7580535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:56:31+00:00 2026-05-30T17:56:31+00:00

I am performing some network related code. When the code starts executing and the

  • 0

I am performing some network related code. When the code starts executing and the user sends the app in background and that time if exception raise the app is killed. if exception is not raised app is not killed. Is it possible to stop/pause any kind of network activity? or a way to stop app from killing?

UPDATE

I am using matt gallahar (cocoa with love) written uncaughtexception handler. How do I cancel the request once it fired. The code for request is called in this function

+(NSString*)validate:(NSString*)username password:(NSString*)password server:(NSString*)server port:(int)port encryption:(int)encryption authentication:(int)authentication folders:(NSMutableArray*)folders {
    CTCoreAccount* account = [[CTCoreAccount alloc] init];

    @try   {
        [account connectToServer:server port:port connectionType:encryption authType:authentication login:username password:password];
    } @catch (NSException *exp) {
        NSLog(@"connect exception: %@", exp);
        return [NSString stringWithFormat:@"Connect error: %@", [ImapFolderWorker decodeError:exp]]; 
    }
}


- (void)connectToServer:(NSString *)server port:(int)port 
        connectionType:(int)conType authType:(int)authType
        login:(NSString *)login password:(NSString *)password {
    int err = 0;
    int imap_cached = 0;

    const char* auth_type_to_pass = NULL;
    if(authType == IMAP_AUTH_TYPE_SASL_CRAM_MD5) {
        auth_type_to_pass = "CRAM-MD5";
    }

    err = imap_mailstorage_init_sasl(myStorage,
                                     (char *)[server cStringUsingEncoding:NSUTF8StringEncoding],
                                     (uint16_t)port, NULL,
                                     conType,
                                     auth_type_to_pass,
                                     NULL,
                                     NULL, NULL,
                                     (char *)[login cStringUsingEncoding:NSUTF8StringEncoding], (char *)[login cStringUsingEncoding:NSUTF8StringEncoding],
                                     (char *)[password cStringUsingEncoding:NSUTF8StringEncoding], NULL,
                                     imap_cached, NULL);

    if (err != MAIL_NO_ERROR) {
        NSException *exception = [NSException
                exceptionWithName:CTMemoryError
                reason:CTMemoryErrorDesc
                userInfo:nil];
        [exception raise];
    }

    err = mailstorage_connect(myStorage);
    if (err == MAIL_ERROR_LOGIN) {
        NSException *exception = [NSException
                exceptionWithName:CTLoginError
                reason:CTLoginErrorDesc
                userInfo:nil];
        [exception raise];
    }
    else if (err != MAIL_NO_ERROR) {
        NSException *exception = [NSException
                exceptionWithName:CTUnknownError
                reason:[NSString stringWithFormat:@"Error number: %d",err]
                userInfo:nil];
        [exception raise];
    }
    else    
        connected = YES;
}

The Exception occurs If I enter different Port number that time the exception raises in the following line

NSException *exception = [NSException
                    exceptionWithName:CTUnknownError
                    reason:[NSString stringWithFormat:@"Error number: %d",err]
                    userInfo:nil];
            [exception raise]; // this line kills the app if the app is in background. 

These functions are in MailCore Library. Now if someone knows the solution please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:56:32+00:00Added an answer on May 30, 2026 at 5:56 pm

    Have you registered an uncaughtExceptionHandler for your application? Also, Apple does recommend that you cancel any open network requests (or at least be prepared for them to fail) prior to shutting down (use - (void)applicationDidEnterBackground:(UIApplication *)application). See the “Being a Responsible Background Application” section of this link: https://developer.apple.com/library/ios/DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW47

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm performing some parameter validation in a method and throwing an exception where necessary.
We are performing some JMeter tests on a JBoss 4.0.5 deployed web app. We
I have a WCF service that is performing some updates across a couple of
I am wanting to store the state of some actions the user is performing
I am performing some simulations in python that generates 1000 results. Each result has
I have a stored procedure that is performing some ddl dml operations. It retrieves
I need a control that allows loading a picture, performing some basic drawing tasks
After performing some tests I noticed that printf is much faster than cout .
When performing some action on another user's repo, you will see the message Not
I've got a web service call performing some validation on user input in real

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.