Thursday 16 August 2012

How to avoid 0x8badf00d crash

0x8badf00d  is a crash that is happening if one of the three methods takes much more time than it should take (around 5 seconds)

There are two on startup, applicationDidFinishLaunching: and application:didFinishLaunchingWithOptions, and one on shutdown, applicationWillTerminate.
But the most important & frequent one is "application:didFinishLaunchingWithOptions".

To avoid this, simply use the following trick

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self.window makeKeyAndVisible];   
    [self.loadingWheel startAnimating];       
   
   
    [self performSelector:@selector(didFinishLaunchingWithOptionsAfterDelay:) withObject:launchOptions afterDelay:0.01];
   
    return YES;
}


- (BOOL)didFinishLaunchingWithOptionsAfterDelay:(NSDictionary *)launchOptions{
   
  //Spend your holiday here :)   
}

As you see, simply call another method after delay & put every line that was in  "application:didFinishLaunchingWithOptions", that solves.

No comments:

Post a Comment