ios 之定时器的使用的技巧(结合runloop)使用

   1.在项目中要使用到定时器,但是遇到了问题就是无法关闭定时器的,在网上找了资料才发生了原来定时器是要结合runloop的使用一起来的呀,不然是无法关闭定时器的使用的

    self.timer1 = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(mythod1) userInfo:nil repeats:YES];

        //将定时器加入到当前的runloop里面

        [[NSRunLoop currentRunLoop]addTimer:self.timer1 forMode:NSRunLoopCommonModes];

      关闭定时器: [self.timer1 setFireDate:[NSDate distantFuture]];

  定时器失效: [self.timer1 invalidate];

 希望对帮助!!!