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