您的位置:首页 > 移动开发 > IOS开发

ios之在子线程中使用定时器

2014-04-15 15:06 246 查看
- (void)viewDidLoad

{

[NSThread detachNewThreadSelector:@selector(timer) toTarget:self withObject:nil];

}

-(void)timer

{

[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(getGPRS) userInfo:nil repeats:YES];

//保持线程为活动状态,才能保证定时器执行

[[NSRunLoop currentRunLoop] run];

}

-(void)getGPRS

{

NSLog(@"NSTimer");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: