Andrea
Andrea

Reputation: 26385

Core data exception: initWithCoder:]: unrecognized selector sent

I'm experiencing this issue using Core Data.

CoreData: error: exception during fetchRowForObjectID: -[PharmaceuticalComp initWithCoder:]: unrecognized selector sent to instance 0x9ab1920 with userInfo of (null)
2014-08-18 07:56:55.784 HorizonMemory[1357:60b] CoreData: error: Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  -[PharmaceuticalComp initWithCoder:]: unrecognized selector sent to instance 0x9ab1920 with userInfo (null)
2014-08-18 07:56:55.786 HorizonMemory[1357:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PharmaceuticalComp initWithCoder:]: unrecognized selector sent to instance 0x9ab1920'
*** First throw call stack:
(
    0   CoreFoundation                      0x021981e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x01f178e5 objc_exception_throw + 44
    2   CoreFoundation                      0x02235243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x0218850b ___forwarding___ + 1019
    4   CoreFoundation                      0x021880ee _CF_forwarding_prep_0 + 14
    5   Foundation                          0x01b2a01a _decodeObjectBinary + 3498
    6   Foundation                          0x01b2b4d7 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 2204
    7   Foundation                          0x01b2b746 -[NSArray(NSArray) initWithCoder:] + 255
    8   Foundation                          0x01b2a01a _decodeObjectBinary + 3498
    9   Foundation                          0x01b2b4d7 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 2204
    10  Foundation                          0x01b37ff1 -[NSDictionary(NSDictionary) initWithCoder:] + 261
    11  Foundation                          0x01b2a01a _decodeObjectBinary + 3498
    12  Foundation                          0x01b29106 _decodeObject + 340
    13  Foundation                          0x01b28faa -[NSKeyedUnarchiver decodeObjectForKey:] + 181
    14  Foundation                          0x01b9aa86 +[NSKeyedUnarchiver unarchiveObjectWithData:] + 106
    15  Foundation                          0x01b197d5 -[_NSKeyedUnarchiveFromDataTransformer transformedValue:] + 47
    16  CoreData                            0x024205b9 _prepareResultsFromResultSet + 4105
    17  CoreData                            0x0241de33 newFetchedRowsForFetchPlan_MT + 1

PharmaComp is an NSManaged subclass linked to another entity User by a transient property -linkedPharma. User has this property in readonly mode. Every time I call linkedPharma it starts a fetch request that provides me the PharmaComp instance. When I try to delete User, i get this exception. the strange fact is that linkedPharma is a property not listed in the Model, thus PharmaComp shouldn't be involved in any sort of operation.The other fact is that it seems to try to use NSKeyedUnarchivier on it, but I don't understand why.
No object is hearing for NSManagedObjectContextObjectsDidChangeNotification.
I have no idea about where it came from.

Upvotes: 0

Views: 1791

Answers (1)

Andrea
Andrea

Reputation: 26385

The solution was pretty simple.
User had also another relationship with a transformable container (NSArray) which was holding (for a bug) a PharmaComp instance.

Upvotes: 1

Related Questions