Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS7 background fetch EXC_BAD_ACCESS
    text
    copied!<p>I'm trying to implement a background fetch method to get new data, but it's giving me an error with an NSMutable Dictionary. Here's my code</p> <p>In my appDelegate under performFetchWithCompletionHandler I have:</p> <pre><code> UINavigationController *navigationController = (UINavigationController*) self.window.rootViewController; id topViewController = navigationController.topViewController; if ([topViewController isKindOfClass:[viewController class]]) { [(viewController*)topViewController autologin]; } else { completionHandler(UIBackgroundFetchResultNewData); } </code></pre> <p>This calls auto login in my view controller</p> <pre><code>- (void) autologin { NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; NSString* username = [defaults valueForKey:@"username"]; NSString* password = [defaults valueForKey:@"password"]; [self login:username password:password]; } </code></pre> <p>Which then calls login</p> <pre><code>- (void)login:(NSString*)username password:(NSString*) password { NSDictionary *login = [[NSDictionary alloc] initWithObjectsAndKeys:username, @"username", password, @"password", NO, @"showNotification", nil]; NSOperationQueue* backgroundQueue = [NSOperationQueue new]; ch = [[backgroundProcess alloc] init]; NSInvocationOperation* operation = [[NSInvocationOperation alloc] initWithTarget:ch selector:@selector(runEvents:) object:login]; [backgroundQueue addOperation:operation]; operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(checkStatus) object:nil]; [backgroundQueue addOperation:operation]; } </code></pre> <p>Everything works if my app is running in the foreground and I call the login function, but with the performFetchWithCompletionHandler as soon as it hits </p> <pre><code>NSDictionary *login = [[NSDictionary alloc] initWithObjectsAndKeys:username, @"username", password, @"password", NO, @"showNotification", nil]; </code></pre> <p>I get EXC_BAD_ACCESS. Any help would be appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload