简体   繁体   中英

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 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM