iPhone,如何避免看门狗因启动时间过长而杀死我的应用程序?

发布于 2024-10-12 09:00:58 字数 739 浏览 4 评论 0原文

通知看门狗我没有处于无限循环并且我仍在加载所以不要杀死我的应用程序的正确方法是什么?

我在崩溃日志中收到 异常类型:00000020 异常代码:0x8badf00d 并且只有当独立于 xcode 从 iphone 运行应用程序时,

代码花费的时间是:

- (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];
 }
}

谢谢。

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 as splah ads.
 }
 else {
//or launch the main interface if there's no connectivity.
  [self DisplayTabbar];
 }
}

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

耶耶耶 2024-10-19 09:00:58

如果您有一些初始化需要很长时间,那么最好在新线程中运行它(通过performSelectorInBackground:withObject:)。然后,您的 UI 将以某种“锁定”状态启动。创建一个“解锁”UI 的方法。作为后台方法的最后一个操作,通过 performSelectorOnMainThread:withObject:waitUntilDone: 运行该解锁方法。

重要的是不要阻塞主线程,以便运行循环可以响应 iOS 事件。这就是为什么你应该避免睡眠或其他阻塞的东西。不过,阻塞另一个线程是可以的。此外,采用基于事件的编程方法也有很大帮助。

更新:

现在,最好使用dispatch_async而不是performSelectorInBackground:withObject:。您仍然应该在 dispatch_async 块内创建一个新的 NSAutoreleasePool 以避免内存泄漏。

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.

回梦 2024-10-19 09:00:58

我认为如果看门狗正在杀死您的应用程序,那么加载时间就会太长,并且您的用户不会等待它。查看一些内存管理技术,您可能需要更好地构建您的项目。

可能有一种方法可以告诉看门狗不要杀死您的应用程序,但我保证您的加载时间会让您的用户感到沮丧,并且您的应用程序将无法获得您想要的外展。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文