此上都是借鉴和总结的内容只做本人复习用。
1、PerformSelector:
[self performSelector:@selector(TestSelector:) withObject:nil afterDelay:1];
注:此方式要求必须在主线程中执行,否则无效。是一种非阻塞的执行方式,暂时未找到取消执行的方法。
2、NSTimer
[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(delayMethod) userInfo:nil repeats:NO];
注:此方式要求必须在主线程中执行,否则无效。是一种非阻塞的执行方式,可以通过NSTimer类的- (void)invalidate;取消执行。
3、NSThread
[NSThread sleepForTimeInterval:2];
注: 使线程沉睡2秒
你给我明天,我能给你未来!
希望能遇到志同道合的朋友一起学习一起进步,有大神帮助!!
有什么不对的,有疑问的,只要我方便都可以联系我
于先生
18841322131