mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-05 17:40:47 +08:00
Added support for selecting object mapping using pattern matching on resourcePath.
This commit is contained in:
@@ -200,15 +200,24 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
- (RKObjectMapping *)configuredObjectMapping {
|
||||
if (self.objectMapping) {
|
||||
return self.objectMapping;
|
||||
}
|
||||
|
||||
return [self.mappingProvider objectMappingForResourcePath:self.resourcePath];
|
||||
}
|
||||
|
||||
- (RKObjectMappingResult*)performMapping:(NSError**)error {
|
||||
NSAssert(_sentSynchronously || ![NSThread isMainThread], @"Mapping should occur on a background thread");
|
||||
|
||||
RKObjectMappingProvider* mappingProvider;
|
||||
if (self.objectMapping) {
|
||||
NSString* rootKeyPath = self.objectMapping.rootKeyPath ? self.objectMapping.rootKeyPath : @"";
|
||||
RKObjectMapping *configuredObjectMapping = [self configuredObjectMapping];
|
||||
if (configuredObjectMapping) {
|
||||
NSString* rootKeyPath = configuredObjectMapping.rootKeyPath ? configuredObjectMapping.rootKeyPath : @"";
|
||||
RKLogDebug(@"Found directly configured object mapping, creating temporary mapping provider for keyPath %@", rootKeyPath);
|
||||
mappingProvider = [RKObjectMappingProvider mappingProvider];
|
||||
[mappingProvider setMapping:self.objectMapping forKeyPath:rootKeyPath];
|
||||
[mappingProvider setMapping:configuredObjectMapping forKeyPath:rootKeyPath];
|
||||
} else {
|
||||
RKLogDebug(@"No object mapping provider, using mapping provider from parent object manager to perform KVC mapping");
|
||||
mappingProvider = self.mappingProvider;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// RestKit
|
||||
//
|
||||
// Created by Blake Watters on 10/18/10.
|
||||
// Copyright 2010 Two Toasters
|
||||
// Copyright 2010 RestKit
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// RestKit
|
||||
//
|
||||
// Created by Blake Watters on 10/18/10.
|
||||
// Copyright 2010 Two Toasters
|
||||
// Copyright 2010 RestKit
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
||||
Reference in New Issue
Block a user