2
我使用RestKit映射RestKit投递响应
NSString* path = [NSString stringWithFormat:@"myPathHere"];
NSDictionary *params = [NSDictionary dictionaryWithKeysAndObjects:@"rating",[rating stringValue], nil];
[[RKObjectManager sharedManager].client post:path params:params delegate:self];
服务器将与我的managedObject“项目”的更新版本响应张贴到URI。
我该如何去映射这个项目。我使用下面的委托方法吗?
- (void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response{}
我知道从这里我可以得到响应JSON值,但是如何将其更改为映射对象呢?
任何帮助,非常感谢。
谢谢!
如果我使用GET,但是我使用POST,这可以正常工作。如果你看applyQueryParams方法,它所做的就是把你的字典传入并用“?”将它附加到路径中。在中间。 – iDev 2012-04-06 15:23:59
你可以设置你的RKObjectRouter为POST。像这样:router = [RKObjectRouter new]; [route route class:[CheckStatus class] toResourcePath:@“/ registration/rest/users/checkstatus”forMethod:RKRequestMethodPOST]; – 2012-04-06 15:39:06
我试过这个,它似乎没有工作。我觉得我正在接近。 *(在下一条评论中)*将导致objectloader didloadobjects被调用bu对象数组为空。 – iDev 2012-04-06 21:26:15