Model loader now maps back into specific model instances when loaded using the manager. Prevents duplication of Core Data objects and lets local/remote objects be fully managed by the loader.

This commit is contained in:
Blake Watters
2010-03-05 11:07:54 -05:00
parent 21b88c3a02
commit 9a87d05faa
2 changed files with 4 additions and 2 deletions

View File

@@ -58,7 +58,8 @@
- (void)processLoadModelInBackground:(RKResponse*)response {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
id model = [_mapper mapFromString:[response payloadString]];
id model = response.request.userData;
[_mapper mapModel:model fromString:[response payloadString]];
[_delegate performSelectorOnMainThread:self.callback withObject:model waitUntilDone:NO];
[pool release];
}
@@ -107,7 +108,7 @@
}
}
// TODO - Implement
// TODO: Implement
- (void)requestDidCancelLoad:(RKRequest*)request {
if ([_delegate respondsToSelector:@selector(requestDidCancelLoad:)]) {
[(NSObject<RKRequestDelegate>*)_delegate requestDidCancelLoad:request];

View File

@@ -178,6 +178,7 @@ static RKModelManager* sharedManager = nil;
}
// TODO: are we responsible for deleting the object too,
// or are we to assume that the caller has/will delete it?
// TODO: Right now we are sending back the response object for deletes. Wrong thing to do???
RKRequest* request = [_client delete:[model memberPath] delegate:delegate callback:callback];
request.userData = model;
return request;