Updates comments on inferMappingsFromObjectTypes and add documentation to the Object Mapping document. Defaulted it to off

as it can complicate things for KVC mappable data.
This commit is contained in:
Blake Watters
2011-07-24 12:28:42 -04:00
parent 3a5354c4a0
commit a0cb33d391
3 changed files with 22 additions and 3 deletions

View File

@@ -172,7 +172,14 @@ typedef enum {
When YES, RestKit will auto-select the appropriate object mapping for a particular object
passed through getObject:, postObject:, putObject:, and deleteObject:.
Default: YES
This is useful when you are working with mappable data that is not identifiable via KVC
and you are sending/receiving objects of the same type. When YES, RestKit will search the
mappingProvider for an object mapping targeting the same type of object that you passed into
getObject:, postObject:, :putObject, or deleteObject: and configure the RKObjectLoader to map
the payload using that mapping. This is merely a convenience for users who are working entirely
with non-KVC mappable data and saves the added step of searching the mapping provider manually.
Default: NO
*/
@property (nonatomic, assign) BOOL inferMappingsFromObjectTypes;

View File

@@ -39,7 +39,7 @@ static RKObjectManager* sharedManager = nil;
_router = [RKObjectRouter new];
_client = [[RKClient clientWithBaseURL:baseURL] retain];
_onlineState = RKObjectManagerOnlineStateUndetermined;
_inferMappingsFromObjectTypes = YES;
_inferMappingsFromObjectTypes = NO;
self.acceptMIMEType = RKMIMETypeJSON;
self.serializationMIMEType = RKMIMETypeFormURLEncoded;

View File

@@ -433,7 +433,19 @@ We have configured a serialization mapping for the object and want to fetch our
[[RKObjectManager sharedManager] postObject:query mapResponseWith:articleMapping delegate:self];
}
```
One inconvenience of working with non-KVC data is that RestKit is completely unable to automatically infer the appropriate mappings for you. If you
happen to be working with data where you post/put an object and receive the same object back, you can instruct RestKit to automatically select the
appropriate object mapping for you:
```objc
[RKObjectManager sharedManager].inferMappingsFromObjectTypes = YES;
[[RKObjectManager sharedManager] postObject:article delegate:self];
```
This will cause RestKit to search the mapping provider for the first registered mapping targeting the `Article` class and configure the
object loader to map the results with that mapping. This is provided as a convenience for users who cannot use KVC mappings and is disabled by
default.
### Core Data
Until now we have focused on transient objects within RestKit. For many applications transient objects are completely the right choice --