Fix for crash when coercing an empty object mapping result set into a singular result with asObject. closes #190

This commit is contained in:
Blake Watters
2011-07-05 16:56:34 -04:00
parent e86507f4ed
commit dddc4c3d0a
4 changed files with 43 additions and 4 deletions

View File

@@ -52,11 +52,14 @@
- (id)asObject {
NSArray* collection = [self asCollection];
if ([collection count] > 1) {
NSUInteger count = [collection count];
if (count > 1) {
RKLogWarning(@"Coerced object mapping result containing %d objects into singular result.", [collection count]);
} else if (count == 1) {
return [collection objectAtIndex:0];
}
return [collection objectAtIndex:0];
return nil;
}
- (NSError*)asError {