-(void)run
{
if (_count==10) {
[_timer invalidate];
}
_count++;
NSLog(@"the value is %d",_count);
}
result:
2014-12-26 20:30:19.549 testApp[24698:196764] the value is 2
2014-12-26 20:30:20.549 testApp[24698:196764] the value is 3
2014-12-26 20:30:21.549 testApp[24698:196764] the value is 4
2014-12-26 20:30:22.549 testApp[24698:196764] the value is 5
2014-12-26 20:30:23.549 testApp[24698:196764] the value is 6
2014-12-26 20:30:24.549 testApp[24698:196764] the value is 7
2014-12-26 20:30:25.548 testApp[24698:196764] the value is 8
2014-12-26 20:30:26.550 testApp[24698:196764] the value is 9
2014-12-26 20:30:27.550 testApp[24698:196764] the value is 10
2014-12-26 20:30:28.549 testApp[24698:196764] hello
2014-12-26 20:30:28.549 testApp[24698:196764] the value is 11