how to call a method of multiple arguments with delay

后端 未结 6 574
谎友^
谎友^ 2020-12-13 04:15

I\'m trying to call a method after some delay.

I know there is a solution for that:

[self performSelector:@selector(myMethod) withObject:nil afterDel         


        
6条回答
  •  执笔经年
    2020-12-13 04:45

    Swift:

        let delayInSeconds = 3.0;
        let delay = delayInSeconds * Double(NSEC_PER_SEC)
        let popTime = dispatch_time(DISPATCH_TIME_NOW, Int64(delay));
        dispatch_after(popTime, dispatch_get_main_queue(), {
            // DO SOMETHING AFTER 3 sec
        });
    

提交回复
热议问题