我正在为测试目的制作基准测试应用程序.我不打算去App Store.
我需要的是我的NSTimer使用UIBackgroundTaskIdentifier继续在后台运行,将数据保存到Core Data数据库,最后在一定的时间间隔之后将数据推送到服务器(我正在使用Parse).
所以基本上,我还没有找到任何适用于我的具体案例的问题.我这样设置我的NSTimer:
UIBackgroundTaskIdentifier bgTask;
UIApplication *app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
}];
self.timer = [NSTimer scheduledTimerWithTimeInterval:self.localInterval target:self selector:@selector(updateCoreData:) userInfo:nil repeats:YES];
Run Code Online (Sandbox Code Playgroud)
方法updateCoreData只调用Core Data类并进行必要的插入.
我已经阅读过有关VoIP和音乐播放部分的内容,但不知道哪一个最适合我的情况,也不知道如何实现它们.