Skip to content

Instantly share code, notes, and snippets.

@shyam-habarakada
Created August 29, 2011 18:19
Show Gist options
  • Save shyam-habarakada/1179009 to your computer and use it in GitHub Desktop.
Save shyam-habarakada/1179009 to your computer and use it in GitHub Desktop.
RestKit error stack trace
2011-08-29 11:14:04.308 APXClient[22687:11f03] -[NSCFString managedObjectContext]: unrecognized selector sent to instance 0xa12a0d0
2011-08-29 11:14:04.310 APXClient[22687:11f03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString managedObjectContext]: unrecognized selector sent to instance 0xa12a0d0'
*** Call stack at first throw:
(
0 CoreFoundation 0x016cb5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0181f313 objc_exception_throw + 44
2 CoreFoundation 0x016cd0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x0163c966 ___forwarding___ + 966
4 CoreFoundation 0x0163c522 _CF_forwarding_prep_0 + 50
5 APXClient 0x000b338b -[RKManagedObjectMapping mappableObjectForData:] + 1225
6 APXClient 0x000865c8 -[RKObjectMapper objectWithMapping:andData:] + 809
7 APXClient 0x00085cdd -[RKObjectMapper mapCollection:atKeyPath:usingMapping:] + 1807
8 APXClient 0x00086eb3 -[RKObjectMapper performMapping] + 2260
9 APXClient 0x0007907d -[RKObjectLoader mapResponseWithMappingProvider:toObject:error:] + 1230
10 APXClient 0x000795e9 -[RKObjectLoader performMapping:] + 989
11 APXClient 0x0007966e -[RKObjectLoader performMappingOnBackgroundThread] + 125
12 Foundation 0x00eb8cf4 -[NSThread main] + 81
13 Foundation 0x00eb8c80 __NSThread__main__ + 1387
14 libsystem_c.dylib 0x9669bed9 _pthread_start + 335
15 libsystem_c.dylib 0x9669f6de thread_start + 34
)
@shyam-habarakada
Copy link
Author

Here are the specific code block in mappableObjectData that is causing the error. It's failing the test because primaryKeyValue is nil, and falling into the else block. Then the insert into context fails.

    if (primaryKeyAttribute && primaryKeyValue) {                
        object = [objectStore findOrCreateInstanceOfEntity:entity withPrimaryKeyAttribute:primaryKeyAttribute andValue:primaryKeyValue];
        NSAssert2(object, @"Failed creation of managed object with entity '%@' and primary key value '%@'", entity.name, primaryKeyValue);
    } else {
        object = [[[NSManagedObject alloc] initWithEntity:entity
                           insertIntoManagedObjectContext:objectStore.managedObjectContext] autorelease];
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment