NSTimer是Cocoa中比较常用的定时器类,基本操作如下:
handleTimer方法可以自行定义。在需要的地方创建timer即可,handleTimer就可以每0.5秒执行一次。
 
- (void) handleTimer: (NSTimer *) timer
{
   //在这里进行处理
}
 
NSTimer *timer;
 
timer = [NSTimer scheduledTimerWithTimeInterval: 0.5
                                                                 target: self
                                                                 selector: @selector(handleTimer:)
                                                                 userInfo: nil
                                                                 repeats: YES];
posted on 2010-04-09 14:56  mac Arthur  阅读(1222)  评论(0编辑  收藏  举报