using iphone sdk 4. I have an NSTimer that calls a method every 3 seconds, however the emethod being called is causing the UI to go unresponsive. I thought the NSTImer callback would happen in a separate thread to the main thread but it appears this is not so.
How can i replace this with an NSOperation or something so th开发者_如何学Ce method is still called every 3 seconds but in a background thread
Your current scenario: "X" method will be called by your time for every 3 seconds. ABC is the task you are performing in "X" method.
What you have to change:
Create a new method "Y". Implement ABC task in "Y" method.
In "X" method (comment all your code in X) and use [self performSelector:@selector(Y) withObject:nil]
Note that above selector works if "Y" method don't take any arguments.
精彩评论