应用程序内部的回调将终止 [英] callbacks inside applicationwillterminate

查看:46
本文介绍了应用程序内部的回调将终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在应用程序终止之前发布一些数据.我通过使用CFStreamCreatePairWithSocketToCFHost生成套接字来做到这一点,后来我有了读写的回调.

I am trying to post some data before my application terminates. Iam doing this by genrateing sockets using CFStreamCreatePairWithSocketToCFHost and later on I have the callbacks for reading and writing.

但是我无法发布任何数据.它遍历所有函数,但不进入回调.这对任何人有意义吗?反正有什么办法让它正常工作?

But I am not able to post any data. It goes through all the functions but doesnot enter into callbacks. Does that make sense to anyone?. Is there anyway to get this working?

谢谢,索里

推荐答案

是的,在调用applicationWillTerminate之后,不再有运行循环的迭代.由于CFSocket和CFStream都使用运行循环来管理套接字并通过回调提供数据,因此将无法使用.同样,非常重要的一点是要注意,在此阶段可能会限制应用程序执行某些操作,并且如果您的应用程序没有终止,则操作系统将终止该应用程序.最好将一个小的日志写入数据库,然后在下次应用程序启动时将该信息发布回去.

Yes, after applicationWillTerminate is called, there are no more iterations of the run loop. Since CFSocket and CFStream both use the run loop to manage the sockets and to provide data via the callback, this will not work. Also, it's very important to note that the application may be restricted from doing certain things at this stage and that if your application does not terminate, the operating system will terminate the application. It may be a better idea to write a small log to a database and then post that information back the next time the application starts.

这篇关于应用程序内部的回调将终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆