RestKit/RestKit — Issue #523: Application crashes when running SenTestingKit Tests with RestKit
Author: lightforce
Created: 2012-01-23 14:13:07+00:00
State: open

When using SenTestingKit (and in my case ARC) the application crashes as soon as Restkit is setup inside the Application Delegate in didFinishLaunchingWithOptions during the test phase. The crash occurs inside NSManagedObject (ActiveRecord):

+ (NSManagedObjectContext*)managedObjectContext {
NSAssert([RKObjectManager sharedManager], @"[RKObjectManager sharedManager] cannot be nil");
NSAssert([RKObjectManager sharedManager].objectStore, @"[RKObjectManager sharedManager].objectStore cannot be nil");
return [[[RKObjectManager sharedManager] objectStore] managedObjectContext];
}

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '[RKObjectManager sharedManager] cannot be nil'

The application crashes although the RKObjectManager shared instance is set explicitly using [RKObjectManager setSharedManager:objectManager];. When the debugger halts on line 31 of NSManagedObject (ActiveRecord), the static, shared instance of RKObjectManager is NOT nil but the assert causes the Application to crash anyway.
Maybe it's related to ARC, but it also crashes when i set a strong reference to the RKObjectManager in the Application Delegate.