what is the proper way to notify the watchdog that i'm not in an endless loop and that i'm still loading so don't kill my app?
I'm receiving in my crashlogs Exception Type: 00000020 Exception Codes: 0x8badf00d and only when running the app from iphone independently from xcode
the code taking time is :
- (void)viewDidLoad {
[super viewDidLoad];
Reachability* reachability = [Reachability sharedReachability];
[reachability setHostName:@"www.apps2you.com"]; // set your host name here
NetworkStatus remoteHostStatus = [reachability remoteHostStatus];
if (remoteHostStatus == ReachableViaWiFiNetwork||remoteHostStatus == ReachableViaCarrierDataNetwork )
{
//getting the xml file and then getting the ad images online to display开发者_StackOverflow社区 as splah ads.
}
else {
//or launch the main interface if there's no connectivity.
[self DisplayTabbar];
}
}
thanks.
If you have some initializing that takes a long time then it's best to run it in a new thread (via performSelectorInBackground:withObject:
). Your UI would then start in some "locked" state. Create a method that "unlocks" the UI. As the very last action of your background method, run that unlock method via performSelectorOnMainThread:withObject:waitUntilDone:
.
It's important not to block the main thread so that the run loop can respond to iOS events. That's why you should avoid sleep
or other blocking stuff. It's alright to block in another thread, though. Also, adapting event-based programming methods help a lot.
Update:
Nowadays, it's better to use dispatch_async
instead of performSelectorInBackground:withObject:
. You still should create a new NSAutoreleasePool
inside the dispatch_async
block to avoid memory leaks.
I think if watchdog is killing your app, then it takes way too long to load and your users wont wait for it. Look at some memory management techniques and you may have to structure your project better.
There may be a way to tell watchdog not to kill your app, but I guarantee your load times will frustrate your users and you won't be getting the out-reach you want with your app.
精彩评论