{"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 在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: (
)
对此问题有任何想法吗?谢谢你的帮助!
答案 0 :(得分:0)
方法
- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)objects{
“objects”数组中是否有任何对象?
这应包含所有个人资料对象。