0
{"avatar_30":"url",
"id": 81,
"name": "\u674e\u5f3a"
}
我有我的配置文件類。RestKit對象映射沒有映射我的對象
@interface Profile: NSObject{
NSNumber* _identifier;
NSString* _name;
NSString* _avatar_30;
}
@property (nonatomic, retain) NSNumber* identifier;
@property (nonatomic, retain) NSString* name;
@property (nonatomic, retain) NSString* avatar_30;
@end
@implementation Profile
@synthesize identifier=_identifier;
@synthesize name=_name;
@synthesize avatar_30 = _avatar_30;
然後,我建我的經理,並獲得Profile類這樣的映射:在AppDelegate.m
UIResponderRKObjectMapping* profileMapping = [RKObjectMapping mappingForClass:[Profile class]];
[profileMapping mapKeyPath:@"id" toAttribute:@"identifier"];
[profileMapping mapKeyPath:@"name" toAttribute:@"name"];
[profileMapping mapKeyPath:@"avatar_30" toAttribute:@"avatar_30"];
RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:_baseURL];
//[manager.mappingProvider setMapping:profileMapping forKeyPath:@"%@"];
[manager loadObjectsAtResourcePath:@"/api/v2/userinfo/100/" objectMapping:profileMapping delegate:self];
我可以得到傑森: 在AppDelegate.h @interface AppDelegate中正確,但是配置文件無法映射。
Got a JSON response back from GET!
2012-04-10 17:47:33.480 Base_01[5714:14603] D restkit.network:RKObjectLoader.m:198 Found directly configured object mapping, creating temporary mapping provider for keyPath '%@'
2012-04-10 17:47:33.482 Base_01[5714:fb03] Load collection of Profiles: (
)
對這個問題有什麼想法嗎?謝謝你的幫助!
對於您的profileMapping測試添加以下行:[[RKObjectManager sharedManager] .mappingProvider setMapping:profileMapping forKeyPath:@「profile」]; – Beber 2012-04-10 13:42:47