NSUserDefaults Unreliable in iOS 8

后端 未结 12 716
北荒
北荒 2020-12-07 17:31

I have an app that uses [NSUserDefaults standardUserDefaults] to store session information. Generally, this information is checked on app launch, and updated on app exit. I

12条回答
  •  天命终不由人
    2020-12-07 17:54

    I have the same problem with iOS 8 and the only solution worked for me is to delay perform of exit() function some duration (Ex.: 0.1 seconds) using:

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC / 10), dispatch_get_main_queue(), ^{ exit(0); });
    

    or create a method and then call it using performSelector:withObject:afterDelay:

    - (void)exitApp {
       exit(0);
    }
    
    [self performSelector:@selector(exitApp) withObject:nil afterDelay:0.1];
    

提交回复
热议问题