I am creating new thread on one button click On other button click i want to stop that thread How to implement it…
I have used
[NSThread exit];
but it freezes my UI…..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
use
-[NSThread cancel]– (void)cancel
Check the cancellation through
-[NSThread isCancelled]or
exit
Terminates the current thread.
This method uses the currentThread class method to access the current thread. Before exiting the thread, this method posts the NSThreadWillExitNotification with the thread being exited to the default notification center. Because notifications are delivered synchronously, all observers of NSThreadWillExitNotification are guaranteed to receive the notification before the thread exits.
Invoking this method should be avoided as it does not give your thread a chance to clean up any resources it allocated during its execution.