RestKit:为postObject调用什么委托方法? [英] RestKit: What delegate method is called for postObject?

查看:114
本文介绍了RestKit:为postObject调用什么委托方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在方法 - (RKObjectLoader *)postObject:(id< NSObject>)对象委托:(id< RKObjectLoaderDelegate>)委托之后调用RKObjectLoaderDelegate的哪种方法?

What method of RKObjectLoaderDelegate gets called after the method - (RKObjectLoader *)postObject:(id<NSObject>)object delegate:(id<RKObjectLoaderDelegate>)delegate is called?

我试图在POST成功后运行更多代码。

I'm trying to run some more code once my POST is successful.

编辑(更多信息):

@Paul提到的方法都没有被调用,但我的服务器正在正确地解释POST,因为数据库正在写入。

Neither of the methods that @Paul mentions are being called, but my server is interpreting the POST somewhat correctly because the DB is being written to.

在应用初始化期间,我正在执行以下操作:

During app initialization, I am doing the following:

// 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];

当我准备发布POST时,我这样做:

And when I am ready to POST, I am doing this:

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 registerMapping:objectMapping withRootKeyPath:@"event_message"];

[[RKObjectManager sharedManager] postObject:eventMessage delegate:self];

这是我在控制台中收到的错误:

And this is the error that I get in the console:


错误域= JKErrorDomain代码= -1意外的令牌,想要'{','}','[',']',',',':', 'true','false','null',''STRING'','NUMBER'。 UserInfo = 0x7b9f510 {JKAtIndexKey = 0,JKLineNumberKey = 1,NSLocalizedDescription =意外的令牌,想要'{','}','[',']',',',':','true','false', 'null','STRING','NUMBER'。}

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'.}


推荐答案

    - (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects;

    - (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error;

这篇关于RestKit:为postObject调用什么委托方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆