首页 > applicationDidEnterBackground 在什么时候被调用

applicationDidEnterBackground 在什么时候被调用

在applicationDidEnterBackground直接NSLog的时候,是可以在退出的时候打印出来的。
但是,如果我在这个段代码里运行一个比较好性能的代码,例如回写缓存之类的。
那么这个代码会不会无法成功执行?


这个方法本来就是用来回写缓存,保存装态之类的吧。至于时间

“Your implementation of this method has approximately five seconds to perform any tasks and return. If you need additional time to perform any final tasks, you can request additional execution time from the system by calling beginBackgroundTaskWithExpirationHandler:. In practice, you should return from applicationDidEnterBackground: as quickly as possible. If the method does not return before time runs out your application is terminated and purged from memory.”

默认有5秒,如果不够可以用beginBackgroundTaskWithExpirationHandler:来延长,这个我没用过,可以google一下。

一般5秒应该够吧了

【热门文章】
【热门文章】