views:

29

answers:

1

Hi!

I have small COCOA Mac OS application to play with core data. I have overridden default save function to do extra job after saving document (automatically save a zip copy also).

Every time I save - program crashes with EXC_BAD_ACCESS in line where I call [super writeToURL ...] The good part is - document is being saved properly. Here is the code:

    - (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...}..
    }

Every time I get similar but not identical stack trace, saying about not recognizing selector or problem with removing something from persistentStoreCoordinator.

My coordinaror is configured simple way:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:

                             [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                             [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

Anyone has a clue wht could be happenin? I could not track it for a long time now...

Debugger stack trace:

 #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:]

thanks

A: 

Thank you guys for help. After recreating tables which were behaving in strange way in xcdatamoel visual view everything works fine now. 2 tables on graph view where joined together while still being visible on the entities list. I could not find a way to separate them without deleting from the model itself.

Lukasz