I have used detachNewThreadSelector method to create threads in my app. At some point of time, when user is logged out from the app, I should kill all running threads in the app. How can I achieve it?
I have used detachNewThreadSelector method to create threads in my app. At some point
Share
If you create a thread with
detachNewThreadSelectoryou pretty much have to let it finish by itself 🙁A better option if you want to be able to control background tasks would be
NSOperationQueue– with this you can pass cancel messages to operations.(Apple docs here)
EDIT : If you don’t want to use NSNotificationCenter, you could set a flag that your background threads periodically check and if it’s set they will exit themselves. However, you would have to be careful about thread safety there 🙂