什么是通知看门狗的正确方法,我不是在无限循环,我仍在加载,所以不要杀我的应用程序?
我在我的崩溃日志中收到异常类型:00000020异常代码:0x8badf00d,仅当从iphone独立运行应用程序时才从xcode
代码花费的时间是:
- (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 as splah ads.
}
else {
//or launch the main interface if there's no connectivity.
[self DisplayTabbar];
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
如果你有一些需要很长时间的初始化,那么最好在一个新线程(via performSelectorInBackground:withObject:
)中运行它.然后,您的UI将以某种"锁定"状态启动.创建一个"解锁"UI的方法.作为后台方法的最后一个操作,运行该解锁方法performSelectorOnMainThread:withObject:waitUntilDone:
.
重要的是不要阻止主线程,以便运行循环可以响应iOS事件.这就是为什么你应该避免sleep
或其他阻止的东西.不过,可以阻止另一个线程.此外,适应基于事件的编程方法有很大帮助.
更新:
如今,最好用dispatch_async
而不是performSelectorInBackground:withObject:
.您仍然应该NSAutoreleasePool
在dispatch_async
块内创建一个新的以避免内存泄漏.
归档时间: |
|
查看次数: |
5440 次 |
最近记录: |