就在 appdelegates 中,applicationDidBecomeActive。我创建并启动一个线程,该线程等待异步下载然后保存数据:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// begins Asynchronous download data (1 second):
[wsDataComponents updatePreparedData:NO];
NSThread* downloadThread = [[NSThread alloc]
initWithTarget:self
selector: @selector (waitingFirstConnection)
object:nil];
[downloadThread start];
}
然后
-(void)waitingFirstConnection{
while (waitingFirstDownload) {
// Do nothing ... Waiting a asynchronous download, Observers tell me when
// finish first donwload
}
// begins Synchronous download, and save data (20 secons)
[wsDataComponents updatePreparedData:YES];
// Maybe is this the problem ?? I change a label in main view controller
[menuViewController.labelBadgeVideo setText:@"123 videos"];
// Nothig else, finish and this thread is destroyed
}
在管理器控制台中,完成后,我收到以下警告:
CoreAnimation: warning, deleted thread with uncommitted CATransaction;