我在进行CoreData请求时(在iOS 10上),遇到了一个奇怪的异常,似乎并不总是发生。我想知道是否有人有任何建议。代码不允许在获取请求中出现空指针,所以不是这个问题。下面是堆栈跟踪,源自一个相当简单的获取:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"user == %@ AND active == 1", activeUser];
[request setPredicate:predicate];
NSArray* result = [syncContext executeFetchRequest:request error:&error];
0 libsystem_kernel.dylib 0x000000018e1a6014 __pthread_kill + 8
1 libsystem_pthread.dylib 0x000000018e26e450 pthread_kill + 112
2 libsystem_c.dylib 0x000000018e11a3e0 abort + 140
3 libsystem_malloc.dylib 0x000000018e1eaa38 _nano_vet_and_size_of_live + 0
4 libsystem_malloc.dylib 0x000000018e1ecbf0 _nano_malloc_check_clear + 392
5 libsystem_malloc.dylib 0x000000018e1ebb3c nano_malloc + 44
6 libsystem_malloc.dylib 0x000000018e1da2c4 malloc_zone_malloc + 172
7 libsqlite3.dylib 0x000000018f6c0c9c 0x18f6be000 + 11420 (sqlite3_config + 1344)
8 libsqlite3.dylib 0x000000018f756f90 0x18f6be000 + 626576 (sqlite3_rekey + 1824)
9 libsqlite3.dylib 0x000000018f6fdfa4 0x18f6be000 + 262052 (sqlite3_log + 90728)
10 libsqlite3.dylib 0x000000018f6f0a94 0x18f6be000 + 207508 (sqlite3_log + 36184)
11 libsqlite3.dylib 0x000000018f6cb238 0x18f6be000 + 53816 (sqlite3_exec + 10664)
12 libsqlite3.dylib 0x000000018f6cab90 0x18f6be000 + 52112 (sqlite3_exec + 8960)
13 libsqlite3.dylib 0x000000018f6c9dc0 0x18f6be000 + 48576 (sqlite3_exec + 5424)
14 libsqlite3.dylib 0x000000018f6c94ac 0x18f6be000 + 46252 (sqlite3_exec + 3100)
15 libsqlite3.dylib 0x000000018f6c9068 0x18f6be000 + 45160 (sqlite3_exec + 2008)
16 CoreData 0x00000001914a2574 -[NSSQLiteConnection prepareSQLStatement:] + 472
17 CoreData 0x00000001915c8364 -[NSSQLiteConnection selectRowsWithStatement:cached:] + 60
18 CoreData 0x00000001915d7684 newFetchedRowsForFetchPlan_MT + 1112
19 CoreData 0x000000019166d670 _executeFetchRequest + 72
20 CoreData 0x0000000191668904 -[NSSQLFetchRequestContext executeRequestUsingConnection:] + 60
21 CoreData 0x000000019157ce98 __52-[NSSQLDefaultConnectionManager handleStoreRequest:]_block_invoke + 260
22 libdispatch.dylib 0x000000018e0611c0 _dispatch_client_callout + 16
23 libdispatch.dylib 0x000000018e06e860 _dispatch_barrier_sync_f_invoke + 84
24 CoreData 0x000000019157cd34 -[NSSQLDefaultConnectionManager handleStoreRequest:] + 208
25 CoreData 0x0000000191642ec4 -[NSSQLCoreDispatchManager routeStoreRequest:] + 288
26 CoreData 0x00000001915abd04 -[NSSQLCore dispatchRequest:withRetries:] + 200
27 CoreData 0x00000001915a6bc4 -[NSSQLCore processFetchRequest:inContext:] + 108
28 CoreData 0x00000001914a9518 -[NSSQLCore executeRequest:withContext:error:] + 504
29 CoreData 0x0000000191589844 __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 4512
30 CoreData 0x0000000191581f90 -[NSPersistentStoreCoordinator _routeHeavyweightBlock:] + 276
31 CoreData 0x00000001914a91cc -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 408
32 CoreData 0x00000001914a7bf4 -[NSManagedObjectContext executeFetchRequest:error:] + 572