我遇到了这个问题,我正在使用 ASIHttpRequest 发出一个需要几分钟的请求,当请求完成时,iPad 处于低功耗状态,屏幕为黑色等。下载的数据保存在 coredata 中处理应用程序崩溃。
这是崩溃信息的一部分:
MyApp[2978] has active assertions beyond permitted time:
{(
<BKProcessAssertion: 0x1f841ec0> identifier: Suspending process: MyApp[2978] permittedBackgroundDuration: 10.000000 reason: suspend owner pid:26 preventSuspend preventThrottleDownCPU preventThrottleDownUI
)}
Elapsed total CPU time (seconds): 10.220 (user 10.220, system 0.000), 51% CPU
Elapsed application CPU time (seconds): 9.860, 49% CPU
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x3c6ae39c pread + 20
1 libsqlite3.dylib 0x3c3b75c8 0x3c3b2000 + 21960
2 libsqlite3.dylib 0x3c3ca0fe 0x3c3b2000 + 98558
3 libsqlite3.dylib 0x3c3c929a 0x3c3b2000 + 94874
4 libsqlite3.dylib 0x3c3e208e 0x3c3b2000 + 196750
5 libsqlite3.dylib 0x3c3e32be 0x3c3b2000 + 201406
6 libsqlite3.dylib 0x3c3df488 0x3c3b2000 + 185480
7 libsqlite3.dylib 0x3c3d8482 sqlite3_step + 2138
8 CoreData 0x340e596a _execute + 122
9 CoreData 0x340e5864 -[NSSQLiteConnection execute] + 2168
10 CoreData 0x341a5486 newFetchedRowsForFetchPlan_MT + 1006
11 CoreData 0x340ec73a -[NSSQLCore objectsForFetchRequest:inContext:] + 678
12 CoreData 0x340ec200 -[NSSQLCore executeRequest:withContext:error:] + 464
13 CoreData 0x340eb618 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1640
14 CoreData 0x340e9f12 -[NSManagedObjectContext executeFetchRequest:error:] + 642
15 Georeporting 0x000b7506 +[Model loadObject:withId:createNew:] (ModelObject.m:51)
16 Georeporting 0x000b18ae -[Data request:didFinished:] (DataManager.m:309)
17 Georeporting 0x000a69fe -[Server requestFinished:] (ServerClient.m:80)
18 Georeporting 0x000e6c04 -[ASIHTTPRequest reportFinished] + 76
这是 executeFetchRequest 的代码
NSEntityDescription * entity = [NSEntityDescription entityForName:[objectClass entityName] inManagedObjectContext:[Model manageObjectContext]];
NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entity];
NSString * query = [NSString stringWithFormat:@"%@='%@'", [objectClass primaryKeyFieldName], objectKey];
NSPredicate * predicate = [NSPredicate predicateWithFormat:query];
[fetchRequest setPredicate:predicate];
NSArray * objects = [[ModelObject manageObjectContext] executeFetchRequest:fetchRequest error:nil];