私の最新の iOS アプリの更新では、DB 関連のクラッシュが大幅に増加しています。DB でフェッチを実行するほぼすべてのコード行でクラッシュが発生しています。
例外:
NSRangeException
* -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
スタックトレース:
CoreFoundation 0x32c982a3 __exceptionPreprocess + 163
1
libobjc.A.dylib 0x3a93d97f objc_exception_throw + 31
2
CoreFoundation 0x32be3b75 -[__NSArrayM objectAtIndex:] + 165
3
CoreData 0x32a4227f -[NSSQLCore _newRowsForFetchPlan:selectedBy:withArgument:] + 2007
4
CoreData 0x32a3b089 -[NSSQLCore newRowsForFetchPlan:] + 313
5
CoreData 0x32a3a73f -[NSSQLCore objectsForFetchRequest:inContext:] + 683
6
CoreData 0x32a3a205 -[NSSQLCore executeRequest:withContext:error:] + 469
7
CoreData 0x32a3961d -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1645
8
CoreData 0x32a37f17 -[NSManagedObjectContext executeFetchRequest:error:] + 647
9
MyApp 0x000516b7 +[DBQuery searchObjectsWithEntityName:::::] + 211
10
MyApp 0x000515a1 +[DBQuery syncData] + 113
11
MyApp 0x0006a7f7 __14+[MyAppSync sync]_block_invoke + 39
12
libdispatch.dylib 0x3ad5511f _dispatch_call_block_and_release + 11
13
libdispatch.dylib 0x3ad63259 _dispatch_root_queue_drain + 261
14
libdispatch.dylib 0x3ad633b9 _dispatch_worker_thread2 + 85
15
libsystem_c.dylib 0x3ad89a11 _pthread_wqthread + 361
16
libsystem_c.dylib 0x3ad898a4 start_wqthread + 8
コードの犯人行は、私の NSFetchRequest の 2 行の変更を追加することに関連している可能性があるようです。
+ (NSFetchRequest*) getFetchRequestForEntityName:(NSString*)entityName :(NSPredicate*)predicate :(NSString*)sortKey :(BOOL)sortAscending :(int)limit :(NSManagedObjectContext*)managedObjectContext
{
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:managedObjectContext];
[request setEntity:entity];
[request setFetchLimit:limit];
//* NEW IN LATEST RELEASE **//
[request setIncludesPropertyValues:NO];
[request setReturnsObjectsAsFaults:NO];
//**************//
if(predicate != nil)
{
[request setPredicate:predicate];
}
// If a sort key was passed, use it for sorting.
if(sortKey != nil)
{
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:sortKey ascending:sortAscending];
NSArray *sortDescriptors = @[sortDescriptor];
[request setSortDescriptors:sortDescriptors];
}
return request;
}