新しいrestkit 10.0のRKObjectMappingと混同しています。RKClient を使用して Web サービスを呼び出し、JSON 形式で応答を取得しました。ここで、JSON 文字列を User クラスにマップします。どうやってするの ?
{"id":2,"displayName":"Giri Bhushan","roles":null,"username":"FBUser-123456","password":"dddddddddddddddd=\r\n","email":"test@gmail.com","gender":"M","birthDate":null,"friends":null,"bloodGroup":null,"firstName":null,"lastName":null,"phoneNumber":null}
以下のコードで試しました:
RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[User class]];
[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 にマップするにはどうすればよいですか?