Reputation: 2035
I am trying to use RestKit on my app, and currently using master on github as a git submodule. The whole thing is installed and running. However, when I try to get JSON data from my rails app, I am getting a BAD_EXC_ACCESS on RestKit, more specifically on RKObjectLoader.m, line 365.
if ([_delegate respondsToSelector:@selector(request:didLoadResponse:)]) {
[_delegate request:self didLoadResponse:_response];
}
Not sure what is going on here but should I assume it is a problem with Restkit?
Here is what I am trying to do:
-(id) init {
self = [super init];
if (self) {
RKObjectMapping* patientMapping = [RKObjectMapping mappingForClass:[Patient class]];
[patientMapping mapKeyPath:@"id" toAttribute:@"identifier"];
[patientMapping mapKeyPath:@"first_name" toAttribute:@"first_name"];
[patientMapping mapKeyPath:@"middle_initial" toAttribute:@"middle_initial"];
[patientMapping mapKeyPath:@"last_name" toAttribute:@"last_name"];
[patientMapping mapKeyPath:@"email" toAttribute:@"email"];
[patientMapping mapKeyPath:@"password_hint_question" toAttribute:@"password_hint_question"];
[patientMapping mapKeyPath:@"password_hint_answer" toAttribute:@"password_hint_answer"];
[[RKObjectManager sharedManager].mappingProvider setMapping:patientMapping forKeyPath:@"patients"];
}
return self;
}
- (void)loadAll {
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/ios_patient.json" delegate:self];
}
So basically I instantiate this class and call loadAll. My ios_patient.json is returning the following JSON code:
{"patients": [{"id": 1, "first_name": "John", "last_name": "Appleseed", "email": "[email protected]"}]}
Any help would be much appreciated.
Upvotes: 0
Views: 469
Reputation: 8741
You can easily use ARC and RestKit, just set the -fno-objc-arc on the RestKit files.
Upvotes: 1
Reputation: 2035
Thanks for the comments. It turns out RestKit is not compatible with ARC and yes, I was using it. The variables were properly mapped (even though they were not camelcase) and the delegates were being properly set and implemented as well. Good thing I am early in the development process and can get back to non ARC.
Upvotes: 0