ios - dispatch_after equivalent in NSOperationQueue -
i'm moving code regular gcd nsoperationqueue because need of functionality. lot of code relies on dispatch_after in order work properly. there way similar nsoperation?
this of code needs converted nsoperation. if provide example of converting using code, great.
dispatch_queue_t queue = dispatch_queue_create("com.cue.mainfade", null); dispatch_time_t mainpoptime = dispatch_time(dispatch_time_now, (int64_t)(timerun * nsec_per_sec)); dispatch_after(mainpoptime, queue, ^(void){ if(dfade !=nil){ double incriment = ([dfade volume] / [self fadeout])/10; //incriment per .1 seconds. [self dodelayfadeout:incriment with:dfade on:dispatch_queue_create("com.cue.mainfade", 0)]; } });
nsoperationqueue
doesn't have timing mechanism in it. if need set delay , execute operation, you'll want schedule nsoperation
dispatch_after
in order handle both delay , making final code nsoperation
.
nsoperation
designed handle more-or-less batch operations. use case different gcd, , in fact uses gcd on platforms gcd.
if problem trying solve cancelable timer notification, i'd suggest using nstimer
, invalidating if need cancel it. then, in response timer, can execute code, or use dispatch queue or nsoperationqueue.
Comments
Post a Comment