Ios 带有嵌套对象的Restkit post

Ios 带有嵌套对象的Restkit post,ios,restkit,restkit-0.20,Ios,Restkit,Restkit 0.20,嗨,我对使用restkit还不熟悉,我对如何发布嵌套对象感到困惑。我试图发布以下json: { "user": { "id": "77777-795C-4374-9A29-5C12FF8031F7", "firstname:": "joe", "lastname": "bob" }, "device": { "token": "phPS2sxbRRvoBbdE8e1VT8nFIJ4R8aJ6rdoCJ8iP1

嗨,我对使用restkit还不熟悉,我对如何发布嵌套对象感到困惑。我试图发布以下json:

{
    "user": {
        "id": "77777-795C-4374-9A29-5C12FF8031F7",
        "firstname:": "joe",
        "lastname": "bob"
    },
    "device": {
        "token": "phPS2sxbRRvoBbdE8e1VT8nFIJ4R8aJ6rdoCJ8iP1luWm3gUJDMnRHBs1SarfosTsIeYMMxwraLCY35B4whaFIISdosHzqa96vkZANHFy5rusHcrnUQuFgJHnsnqOsgxgOPd8QbrZAAxIlmqCt0an5pH69PWZAXcOVuzFilo310oeNW04qWZCWb8GWYMkODcMuUZANCAAFfvZB4ZAyokBADz"
    }
}
我使用的是Restkit版本0.20.3

这就是我的映射的样子:

RKObjectMapping *userMapping = [RKObjectMapping requestMapping];

[userMapping addAttributeMappingsFromDictionary:@{
                                                      @"id": @"id",
                                                      @"firstname": @"firstname",
                                                      @"lastname": @"lastname"
                                                      }];

RKObjectMapping *deviceMapping = [RKObjectMapping requestMapping];
[facebookMapping addAttributeMappingsFromDictionary:@{
                                                     @"token": @"token"
                                                     }];

RKObjectMapping *authMapping = [RKObjectMapping requestMapping];

[authMapping addPropertyMapping:[RKRelationshipMapping
 relationshipMappingFromKeyPath:@"user"
                      toKeyPath:@"user"
                    withMapping:userMapping]];

[authMapping addPropertyMapping:[RKRelationshipMapping
 relationshipMappingFromKeyPath:@"device"
                      toKeyPath:@"device"
                    withMapping:deviceMapping]];

RKRequestDescriptor *authDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:authMapping objectClass:[AuthCredentials class] rootKeyPath:nil method:RKRequestMethodPOST];
[manager addRequestDescriptor:authDescriptor];

User *user = [[User alloc] init];
user.id = @"77777-795C-4374-9A29-5C12FF8031F7";
user.firstname = @"joe";
user.lastname = @"bob";

Device *device = [[Device alloc] init];
device.token = @"phPS2sxbRRvoBbdE8e1VT8nFIJ4R8aJ6rdoCJ8iP1luWm3gUJDMnRHBs1SarfosTsIeYMMxwraLCY35B4whaFIISdosHzqa96vkZANHFy5rusHcrnUQuFgJHnsnqOsgxgOPd8QbrZAAxIlmqCt0an5pH69PWZAXcOVuzFilo310oeNW04qWZCWb8GWYMkODcMuUZANCAAFfvZB4ZAyokBADz";

AuthCredentials *cred = [[AuthCredentials alloc] init];
cred.user = user;
cred.device = device;

[manager postObject:cred path:@"/testpost" parameters:nil
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult)
 {

 }
failure:^(RKObjectRequestOperation *operation, NSError *error)
 {

}];
我的错误消息如下: Error Domain=org.restkit.restkit.ErrorDomain Code=1001“在搜索的关键路径中未找到可映射的对象表示形式。”UserInfo=0x9427070{DetailedErrors=( ),NSLocalizedFailureReason=映射操作无法在搜索的关键路径中找到任何嵌套对象表示形式: 发现输入到映射器的表示在以下关键路径中包含嵌套对象表示:错误
这可能表明您错误配置了映射的键路径。NSLocalizedDescription=在搜索的键路径中未找到可映射的对象表示形式。keyPath=null}

您尝试了什么?显示您当前的映射、请求描述符和发布方法。这只占请求信息的三分之一。。。此外,您会遇到什么错误?根据映射,您还需要提供您正在发布的对象的详细信息(它需要有正确的键)。您的请求映射看起来正常。该错误似乎与响应映射有关,其中服务器返回一个
错误
,而您的响应描述符无法处理该错误。打开跟踪日志记录并使用Charles查看发送和接收的内容。显示您的
postObject
方法。同时展示你是如何为这篇文章编写词典的。最后包括来自服务器的响应。