Queue 是一个支持持久化后台作业队列的 iOS 开发包。示例代码:
- (void)applicationDidBecomeActive:(UIApplication *)application { [[EDQueue sharedInstance] setDelegate:self]; [[EDQueue sharedInstance] start]; } - (void)applicationWillResignActive:(UIApplication *)application { [[EDQueue sharedInstance] stop]; } - (EDQueueResult)queue:(EDQueue *)queue processJob:(NSDictionary *)job { sleep(1); // This won't block the main thread. Yay! // Wrap your job processing in a try-catch. Always use protection! @try { if ([[job objectForKey:@"task"] isEqualToString:@"success"]) { return EDQueueResultSuccess; } else if ([[job objectForKey:@"task"] isEqualToString:@"fail"]) { return EDQueueResultFail; } } @catch (NSException *exception) { return EDQueueResultCritical; } return EDQueueResultCritical; }