调用-(RKObjectLoader *)postObjectid)object delegateid)delegate 方法后调用RKObjectLoaderDelegate的什么方法?
一旦我的 POST 成功,我会尝试运行更多代码。
编辑(更多信息):
@Paul 提到的两种方法都没有被调用,但我的服务器对 POST 的解释有些正确,因为正在写入数据库。
在应用初始化期间,我正在执行以下操作:
// Grab the reference to the router from the manager
RKObjectRouter *router = [RKObjectManager sharedManager].router;
// Define a default resource path for all unspecified HTTP verbs
[router routeClass:[EventMessage class] toResourcePath"/events_messages/:idPrimaryKey"];
[router routeClass:[EventMessage class] toResourcePath"/event_messages" forMethod:RKRequestMethodPOST];
当我准备发布时,我正在这样做:
RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[EventMessage class]];
[objectMapping mapKeyPath"user_id" toAttribute"userId"];
[objectMapping mapKeyPath"event_id" toAttribute"eventId"];
[objectMapping mapKeyPath"message" toAttribute"message"];
[[RKObjectManager sharedManager].mappingProvider registerMappingbjectMapping withRootKeyPath"event_message"];
[[RKObjectManager sharedManager] postObject:eventMessage delegate:self];
这是我在控制台中遇到的错误:
Error Domain=JKErrorDomain Code=-1 "Unexpected token, wanted '{', '}', '[', ']', ',', ':', 'true', 'false', 'null', '"STRING"', 'NUMBER'." UserInfo=0x7b9f510 {JKAtIndexKey=0, JKLineNumberKey=1, NSLocalizedDescription=Unexpected token, wanted '{', '}', '[', ']', ',', ':', 'true', 'false', 'null', '"STRING"', 'NUMBER'.}
Best Answer-推荐答案 strong>
- (void)objectLoaderRKObjectLoader*)objectLoader didLoadObjectsNSArray*)objects;
或
- (void)objectLoaderRKObjectLoader*)objectLoader didFailWithErrorNSError*)error;
关于ios - RestKit:postObject 调用了什么委托(delegate)方法?,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/10307649/
|