在我的应用程序中,我需要使用Grand Central Dispatch(CGD)在后台执行大量操作(调整一组图像)。
我有类EngineViewController
,它是应用程序的rootViewController:
AppDelegate.m
EngineViewController * engineVc = [[EngineViewController alloc]init];
self.window.rootViewController = engineVC;
在viewDidAppear
的{{1}}方法中,我有以下代码:
engineVC
方法- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//this method resize a set of image and save them in Document Folder of the app
//this method needs about 40 seconds to perform all operations
[[JSONParser sharedJSONParser]writeToDiskResizedImage];
NSLog(@"Finished");
});
}
返回后,[[JSONParser sharedJSONParser]writeToDiskResizedImage]
在控制台中打印消息,应用程序崩溃。我的所有项目都是ARC,是NSLog
课程的执行者。在控制台中没有错误消息;我只有这个:
从JSONParser
执行的代码如下:
[[JSONParser sharedJSONParser]writeToDiskResizedImage]