nsTimer的简单用法

    //用nstimer的用法 一种用法,要手动加入到NsRunLoop中
     NSTimer *time= [NSTimer timerWithTimeInterval:3 target:self selector:@selector(NoticeTransation) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:time forMode:NSDefaultRunLoopMode];//手动加入到NSRunLoop中
    [time fire];//立即触发定时器
    
    //第二种方法
   NSTimer *timer= [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(NoticeTransation) userInfo:nil repeats:YES];
    [timer fire];

参考文章http://blog.csdn.net/samuelltk/article/details/7484533

原文地址:https://www.cnblogs.com/gcb999/p/3312062.html