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");
}
{
[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");
}
相关文章推荐
- IOS在子线程中使用定时器,将定时器添加至RunLoop中
- IOS在子线程中使用定时器,将定时器添加至RunLoop中(转)
- iOS使用定时器,并添加到子线程运行
- IOS在子线程中使用定时器,将定时器添加至RunLoop中
- IOS在子线程中使用定时器,将定时器添加至RunLoop中
- IOS在子线程中使用定时器,将定时器添加至RunLoop中
- iOS中最全的各种定时器使用教程
- iOS中定时器NSTimer的使用
- iOS中定时器NSTimer的使用
- 线程互斥锁的问题(线程中使用定时器信号)
- ios 线程、定时器
- iOS中定时器NSTimer的使用
- iOS-子线程与主线程嵌套使用
- java中使用线程实现Timer(定时器)原理和源码
- IOS多线程 - 使用线程加载一张图片 - NSThread(1)(转)
- iOS中定时器NSTimer的使用
- 【iOS开发-多线程】使用NSOperation创建线程(使用较多)
- iOS多线程编程——线程锁的使用
- iOS使用[核心动画]和[定时器]两种方式实现【呼吸灯动画】(仿蘑菇街价格标签)
- iOS中Bonjour:NSNetServiceBrowser在子线程上使用