iOS 应用程序从应用程序切换器中滑动时调用哪个事件?
Which event is called when iOS app is swiped from app switcher?
我想知道当我从应用程序切换器中滑出我的 运行ning 应用程序时,调用了我的 AppDelegate 中的哪个事件?我的目标 iOS 是 >= 7.0(即支持多任务处理)。
也许我只是不了解多任务处理范例本身...当我从应用程序切换器中滑出我的应用程序时,应用程序将被终止,对吧?还是在后台继续 运行ning?
EDIT-1: 为什么我要问:在应用程序启动期间,我通过普通套接字连接到我的 Linux 游戏服务器。我想在应用程序终止时断开套接字。
EDIT-2: 我不确定我是否在使用后台执行。我在 运行-loop 对象中注册我的网络套接字,以异步接收来自服务器套接字的输入。此外,我安装了一种网络服务,可以定期测试网络连接。此服务正在使用 SCNetworkReachabilityScheduleWithRunLoop。
它是 - (void)applicationWillTerminate:(UIApplication *)application
有些情况下 applicationWillTerminate:
会被调用,有时不会。
中阅读更多内容
摘录:
For apps that do not support background execution or are linked
against iOS 3.x or earlier, this method is always called when the user
quits the app. For apps that support background execution, this method
is generally not called when the user quits the app because the app
simply moves to the background in that case. However, this method may
be called in situations where the app is running in the background
(not suspended) and the system needs to terminate it for some reason.
有趣的是
After calling this method, the app also posts a
UIApplicationWillTerminateNotification notification to give interested
objects a chance to respond to the transition.
我想知道当我从应用程序切换器中滑出我的 运行ning 应用程序时,调用了我的 AppDelegate 中的哪个事件?我的目标 iOS 是 >= 7.0(即支持多任务处理)。
也许我只是不了解多任务处理范例本身...当我从应用程序切换器中滑出我的应用程序时,应用程序将被终止,对吧?还是在后台继续 运行ning?
EDIT-1: 为什么我要问:在应用程序启动期间,我通过普通套接字连接到我的 Linux 游戏服务器。我想在应用程序终止时断开套接字。
EDIT-2: 我不确定我是否在使用后台执行。我在 运行-loop 对象中注册我的网络套接字,以异步接收来自服务器套接字的输入。此外,我安装了一种网络服务,可以定期测试网络连接。此服务正在使用 SCNetworkReachabilityScheduleWithRunLoop。
它是 - (void)applicationWillTerminate:(UIApplication *)application
有些情况下 applicationWillTerminate:
会被调用,有时不会。
摘录:
For apps that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the app. For apps that support background execution, this method is generally not called when the user quits the app because the app simply moves to the background in that case. However, this method may be called in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason.
有趣的是
After calling this method, the app also posts a UIApplicationWillTerminateNotification notification to give interested objects a chance to respond to the transition.