我對新的restkit 10.0中的RKObjectMapping感到困惑。 我已經用RKClient調用了我的webservice,並以JSON的形式得到響應。 現在我想用我的User類來映射JSON字符串。 如何做到這一點?restkit 10.0中的RKObjectMapping映射問題
塊引用 { 「ID」:2 「顯示名」: 「吉瑞普山」, 「角色」:NULL, 「用戶名」: 「FBUser-123456」, 「密碼」:「dddddddddddddddd = \ r \ N」, 「電子郵件」: 「[email protected]」, 「性別」: 「M」, 「生日」:空, 「朋友」:空, 「bloodGroup」:空, 「名字」:空, 「姓氏」 :NULL, 「phoneNumber的」 日期null}
我試圖與下面的代碼:
RKObjectMapping * userMapping = [RKObjectMapping mappingForClass:[用戶類]]; [userMapping mapKeyPath:@「id」toAttribute:@「userId」];
[userMapping mapKeyPath:@"displayName" toAttribute:@"displayName"];
[userMapping mapKeyPath:@"userName" toAttribute:@"userName"];
[userMapping mapKeyPath:@"password" toAttribute:@"password"];
[userMapping mapKeyPath:@"email" toAttribute:@"email"];
[userMapping mapKeyPath:@"gender" toAttribute:@"gender"];
[userMapping mapKeyPath:@"birthDate" toAttribute:@"birthDate"];
[userMapping mapKeyPath:@"bloodGroup" toAttribute:@"bloodGroup"];
[userMapping mapKeyPath:@"firstName" toAttribute:@"firstName"];
[userMapping mapKeyPath:@"lastName" toAttribute:@"lastName"];
[userMapping mapKeyPath:@"phoneNumber" toAttribute:@"phoneNumber"];
[[RKObjectManager sharedManager].mappingProvider setMapping:userMapping forKeyPath:@"user"];
但是,我怎麼映射JSON字符串RKObjectMapping?