iPhone - a delay between operations in the queue

后端 未结 4 1862
挽巷
挽巷 2021-02-03 15:20

I am adding operations to the queue using something like this

NSInvocationOperation *operation0 = [[NSInvocationOperation alloc] 
initWithTarget:self
selector:@s         


        
4条回答
  •  迷失自我
    2021-02-03 15:41

    I have two ways to do such thing.

    First: Let the current thread to sleep on the tail of doStuff1, doStuff2, and doStuff3.

    Second: Sub-class NSOperation and override the method -(void)main. You can init a custom NSOperation with parameters of target and action like following:

    -(id)initWithTarget:(id)target action:(SEL)action;
    

    And execute this action of target in the -(void)main by

    [target performSelector:action];
    [NSThread sleepForTimeInterval:0.05];
    

提交回复
热议问题