我有一个小的COCOA Mac OS应用程序来玩核心数据。 我已经覆盖默认保存功能,在保存文件后做额外的工作(也自动保存拉链副本)。
每次我保存 - 程序崩溃与EXC_BAD_ACCESS排队我调用[super writeToURL ...] 好的部分是 - 正确保存文档。这是代码:
- (BOOL)writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation originalContentsURL:(NSURL *)absoluteOriginalContentsURL error:(NSError **)error{
NSLog(@"Overriding SAVE operation");
// Crash everytime with objc_msSend or EXC_BAD_ACCESS (but saves properly):
BOOL res = [super writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation originalContentsURL:(NSURL *)absoluteOriginalContentsURL error:(NSError **)error];
if(res){ // zip and save zipped copy...}..
}
每次我得到类似但不相同的堆栈跟踪时,说不能识别选择器或从persistentStoreCoordinator中删除某些东西的问题。
我的协调员配置简单:
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
任何人都有可能发生的线索? 我现在很难跟踪它......
调试器堆栈跟踪:
#0 0x9141f4e6 in objc_exception_throw
#1 0x951288e8 in +[NSException raise:format:arguments:]
#2 0x9512885a in +[NSException raise:format:]
#3 0x956837dc in -[_NSManagedProxy _entity]
#4 0x9568392a in -[_NSManagedProxy fetchRequestWithSortDescriptors:limit:]
#5 0x95961f4a in -[_NSManagedProxy _storesDidChange:]
#6 0x95f801c3 in _nsnote_callback
#7 0x950b03c3 in __CFXNotificationPost
#8 0x950afdca in _CFXNotificationPostNotification
#9 0x95f75090 in -[NSNotificationCenter postNotificationName:object:userInfo:]
#10 0x906da1dc in -[NSPersistentStoreCoordinator(_NSInternalMethods) _postStoresChangedNotificationsForStores:changeKey:options:]
#11 0x906cbd52 in -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]
#12 0x9597f2e7 in -[NSPersistentDocument configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:]
#13 0x00002a35 in -[MyDocument configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:] at MyDocument.m:79
#14 0x95c3536f in -[NSPersistentDocument(NSDeprecatedInternal) _configurePersistentStoreCoordinatorForURL:ofType:error:]
#15 0x9597f585 in -[NSPersistentDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:]
#16 0x00002ab9 in -[MyDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:] at MyDocument.m:90
#18 0x95822a4a in -[NSDocument writeSafelyToURL:ofType:forSaveOperation:error:]
感谢
答案 0 :(得分:0)
谢谢你们的帮助。在xcdatamoel视觉视图中重新创建以奇怪方式运行的表后,现在一切正常。图表视图上的2个表连接在一起,同时仍在实体列表中可见。我没有找到一种方法来分离它们而不删除模型本身。