我坚持如何构建我的对象和映射以通过PUT-Method放入数据时实现类似的事情:“lastChanges / confirm”
上述PUT-Request接受这样的正文以确认box id的同步:
{ "synchronized_boxes": [47292,someOtherBoxId,..] }
我尝试构建这样的对象:
@interface RPConfirmSync : NSObject
@property (nonatomic, retain) NSArray *synchronized_boxes;
@end
在发送此对象之前,我将一些NSNumber对象添加到数组中。
我设置的映射如下所示:
RKObjectMapping *confirmMapping = [RKObjectMapping mappingForClass:[RPConfirmSync class]];
[confirmMapping addAttributeMappingsFromArray:@[@"synchronized_boxes"]];
RKObjectMapping *requestMapping = [confirmMapping inverseMapping];
NSString *pathPattern = [NSString stringWithFormat:@"lastsync/confirm"];
RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:requestMapping objectClass:[RPConfirmSync class] rootKeyPath:nil];
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:confirmMapping pathPattern:pathPattern keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[self.objectManager addRequestDescriptor:requestDescriptor];
[self.objectManager addResponseDescriptor:responseDescriptor];
现在,当我执行上面的PUT-Request并查看请求体时,RestKit Debug信息向我展示了一些奇怪的东西:
request.body=synchronized_boxes[]=47292 //being sent to the server !ERROR!
应该是
request.body=synchronized_boxes[47292]
如何设置我的对象或映射是否有问题?我真的被困在这里,虽然我猜答案是直截了当的。