在iOS 10中完美運行。在將iOS更新爲iOS11後,應用程序崩潰時將數據保存到核心數據中,但有一個例外。 爲coredata我已經使用RZVinyl框架在iOS11中保存核心數據時應用程序崩潰
BOOL isSaved = [currentContext save:&saveErr];
斷言失敗:(moreParameters-> mostRecentEntry == CFArrayGetValueAtIndex(堆棧,stackCount - 1)),函數 NSKeyValuePopPendingNotificationPerThread,文件 /buildroot的/庫/高速緩存/com.apple.xbs/Sources/Foundation_Sim/Foundation-1444.12/EO.subproj/NSKeyValueObserving.m,線933
0 libsystem_kernel.dylib 0x00000001826fd348 __pthread_kill + 8 1 libsystem_pthread.dylib 0x0000000182811354 pthread_kill$VARIANT$mp + 396 2 libsystem_c.dylib 0x000000018266cfd8 abort + 140 3 libsystem_c.dylib 0x0000000182640abc basename_r + 0 4 Foundation 0x00000001834f1a9c -[NSRunLoop+ 178844 (NSRunLoop) runUntilDate:] + 0 5 Foundation 0x00000001834df538 NSKeyValueDidChange + 436 6 Foundation 0x0000000183597ae4 NSKeyValueDidChangeWithPerThreadPendingNotifications + 140 7 CoreData 0x00000001854107c8 -[NSManagedObject didChangeValueForKey:] + 120 8 CoreData 0x0000000185416358 -[NSManagedObject+ 844632 (_NSInternalMethods) _updateFromRefreshSnapshot:includingTransients:] + 692 9 CoreData 0x000000018542e054 -[NSManagedObjectContext+ 942164 (_NestedContextSupport) _copyChildObject:toParentObject:fromChildContext:] + 652 10 CoreData 0x000000018542e4bc -[NSManagedObjectContext+ 943292 (_NestedContextSupport) _parentProcessSaveRequest:inContext:error:] + 804 11 CoreData 0x000000018542f3f0 __82-[NSManagedObjectContext+ 947184 (_NestedContextSupport) executeRequest:withContext:error:]_block_invoke + 580 12 CoreData 0x0000000185431644 internalBlockToNSManagedObjectContextPerform + 92 13 libdispatch.dylib 0x0000000182569048 _dispatch_client_callout + 16 14 libdispatch.dylib 0x0000000182571ae8 _dispatch_queue_barrier_sync_invoke_and_complete + 56 15 CoreData 0x000000018541dd10 _perform + 232 16 CoreData 0x000000018542f0e4 -[NSManagedObjectContext+ 946404 (_NestedContextSupport) executeRequest:withContext:error:] + 172 17 CoreData 0x0000000185387ff8 -[NSManagedObjectContext save:] + 2580
NSManagedObjectContext *currentContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
[[currentContext userInfo] setObject:self forKey:kRZCoreDataStackParentStackKey];
[self performBlock:^{
BOOL hasChanges = [currentContext hasChanges];
if (!hasChanges) {
RZVLogInfo(@"Managed object context %@ does not have changes, not saving", self);
rzv_performSaveCompletionAsync(completion, nil);
return;
}
NSError *saveErr = nil;
BOOL isSaved = [currentContext save:&saveErr];
if (!isSaved) {
RZVLogError(@"Error saving managed object context context %@: %@", self, saveErr);
rzv_performSaveCompletionAsync(completion, saveErr);
}
}];
這與項目非常接近。在很多地方使用它們。我可以有一些解決你的錯誤的示例代碼。 – Joe
這與項目非常接近。在很多地方使用它們。我是否可以提供一些修正錯誤的示例代碼,並且還可以改爲「確保如果您通過willChangeValue和didChangeValue觀察更改以更新關於此更改的關係,請不要更新,如果觀察者是正在設置的觀察者「。它有點混亂。 – Joe
非常感謝Oren。你的例子很清楚,解決了我的問題。 – Joe