iphone应用程序后台NSTimer(定期轮询数据)
我需要定期从服务器后台获取数据,iphone应用程序后台NSTimer(定期轮询数据),iphone,background,nstimer,Iphone,Background,Nstimer,我需要定期从服务器后台获取数据, Nstimer在后台似乎不起作用 我需要为Void或audio编辑plist以使NStimer在后台工作吗? 有人会解释我们示例代码的过程吗 问候,, Avinash查看此方法: [NSThread detachNewThreadSelector: toTarget: withObject:] 用法示例: -(void) pollBackground { @autoreleasepool { // every five se
Nstimer在后台似乎不起作用 我需要为Void或audio编辑plist以使NStimer在后台工作吗? 有人会解释我们示例代码的过程吗 问候,, Avinash查看此方法:
[NSThread detachNewThreadSelector: toTarget: withObject:]
用法示例:
-(void) pollBackground
{
@autoreleasepool {
// every five seconds, update list
NSTimeInterval interval = 5;
while (poll)
{
// update from server
[NSThread sleepForTimeInterval:interval];
}
}
}
-(void) viewDidLoad {
[NSThread detachNewThreadSelector:@selector(pollBackground) toTarget:self withObject:nil];
}
这应该在后台运行。“Nstimer似乎在后台不工作。”代码?我想他是想说,当他的应用程序处于后台时,他的代码不会运行,因为应用程序已挂起。是的,在挂起模式下,我会继续从服务器轮询数据。我需要在应用程序处于后台模式时访问数据,当用户点击“主页按钮”时