Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iphone应用程序后台NSTimer(定期轮询数据)_Iphone_Background_Nstimer - Fatal编程技术网

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似乎在后台不工作。”代码?我想他是想说,当他的应用程序处于后台时,他的代码不会运行,因为应用程序已挂起。是的,在挂起模式下,我会继续从服务器轮询数据。我需要在应用程序处于后台模式时访问数据,当用户点击“主页按钮”时