搜索
ios - applicationDidEnterBackground 在什么时候被调用
PHPz
PHPz 2017-04-17 11:21:54
[iOS讨论组]

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

PHPz
PHPz

学习是最好的投资!

全部回复(1)
伊谢尔伦

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

“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秒应该够吧了

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号