{"avatar_30":"url",
"id": 81,
"name": "\u674e\u5f3a"
}
我有我的个人资料课程。
@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 Class 的映射:在 AppDelegate.h @interface AppDelegate : UIResponder in AppDelegate.m
RKObjectMapping* 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];
我可以正确获取 jason,但是无法映射配置文件。
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: (
)
有人对这个问题有任何想法吗?谢谢你的帮助!