用什么方法RKObjectLoaderDelegate的获取方法之后调用- (RKObjectLoader *)postObject:(id<NSObject>)object delegate:(id<RKObjectLoaderDelegate>)delegate
被称为?
我想一旦我的POST成功运行更多的代码。
编辑(详细信息):
无论是那@保罗提到的方法被调用,但我的服务器在某种程度上正确地解释POST因为DB被写入。
在应用程序初始化时,我做了以下内容:
// 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 registerMapping:objectMapping withRootKeyPath:@"event_message"];
[[RKObjectManager sharedManager] postObject:eventMessage delegate:self];
这是我在控制台得到的错误:
错误域= JKErrorDomain代码= -1“意外的道理,想 '{', '}', '[', ']',”, ' ':', '真', '假', '空',' “STRING””, '号'。” 的UserInfo = 0x7b9f510 {JKAtIndexKey = 0,JKLineNumberKey = 1,NSLocalizedDescription =意外标记,想 '{', '}', '[', ']', '', ':', '真', '假', '空', ' “STRING”', '号'。}