how to stop running thread if app went to background mode in iphone?
I am开发者_开发百科 creating an iphone application which i need to stop a running thread if the application went to background mode,is it possible to stop thread in iphone application? as because my thread displays location notification alert messages continuously if application enter to foreground .
Please help me if any one knows. Thanks in advance.
If your app was switched to the background, the OS will let you know by calling one of your delegate's methods:
- (void)applicationDidEnterBackground:(UIApplication *)application {
Your app won't be frozen right away. You can immediately contact your server (if any) or any controller within your app and stop displaying notifications.
btw: I suggest you first test your app on a real device to see how it behaves when switched to the background. It is possible that the OS will freeze that thread for you. Nothing might have to be done on your side.
This Tutorial will guide you what you want to achieve.
精彩评论