OStack程序员社区-中国程序员成长平台

标题: ios - RestKit:postObject 调用了什么委托(delegate)方法? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 20:33
标题: ios - RestKit:postObject 调用了什么委托(delegate)方法?

调用-(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-推荐答案


    - (void)objectLoaderRKObjectLoader*)objectLoader didLoadObjectsNSArray*)objects;

    - (void)objectLoaderRKObjectLoader*)objectLoader didFailWithErrorNSError*)error;

关于ios - RestKit:postObject 调用了什么委托(delegate)方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10307649/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4