timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(function:) userInfo:nil repeats:YES];
注意:将计数器的repeats设置为YES的时候,self的引用计数会加1。因此可能会导致self(即viewController)不能release,所以,必须在viewWillDisappear的时候,将计数器timer停止,否则可能会导致内存泄露。
//取消定时器
[timer invalidate];
原文来自:http://blog.csdn.net/enuola/article/details/8099461