Calling a method at a specific time
I've created a recorder that stores the CFAbsoluteTime of a triggered sound and the name of it in two separate arrays. In order to play the recording back, I need a time-accurate way of calling the trigger sound method. Preferably it should be non-processor intensive; I did something a while back that worked accurately but hogged all of the iphone's memory.
For example, I've tried NSTimer which seems to lag a bit with non-exact playback, and NSThread which was memory intensive.
What are some of my 开发者_JAVA百科options, with pros and cons? Thanks.
What do you think about doing something like this:
[self performSelector:@selector(playSound) withObject:nil afterDelay:0.2];
Check the dispatch_later
documentation. It is more flexible and guaranteed to run in the estimated time than using performSelector:afterDelay;
精彩评论