Allow modification of the data in objectLoader:willMapData: by creating a mutable copy of the parsed data if the delegate method is implemented.

This commit is contained in:
Blake Watters
2011-06-27 16:37:55 -04:00
parent e4320f7ea9
commit 0949337749
4 changed files with 37 additions and 2 deletions

View File

@@ -58,7 +58,8 @@
/**
Invoked just after parsing has completed, but before object mapping begins. This can be helpful
to extract data from the parsed payload that is not object mapped, but is interesting for one
reason or another.
reason or another. The mappableData will be made mutable via mutableCopy before the delegate
method is invoked.
*/
- (void)objectLoader:(RKObjectLoader*)loader willMapData:(id)mappableData;

View File

@@ -131,6 +131,7 @@
}
if ([self.delegate respondsToSelector:@selector(objectLoader:willMapData:)]) {
parsedData = [[parsedData mutableCopy] autorelease];
[(NSObject<RKObjectLoaderDelegate>*)self.delegate objectLoader:self willMapData:parsedData];
}