首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RestKit 0.2 - Error Domain=org.restkit.RestKit.ErrorDomain Code=1001

RestKit 0.2 - Error Domain=org.restkit.RestKit.ErrorDomain Code=1001
EN

Stack Overflow用户
提问于 2012-12-05 08:03:50
回答 3查看 1.6K关注 0票数 2

我刚刚更新到RestKit 0.20,我正在用头撞我的桌面,试图弄清楚为什么我的相册对象不能映射。response对象没有keyPath参数,但之前将其设置为@"“有效。

以下是返回的数据片段:

代码语言:javascript
复制
[
  {
    id: "337",
    title: "Hockey",
    description: "",
    location: "",
    date_created: "1353424563",
    date_modified: "1353424563",
    featured_image: "album_default.png",
    featured_thumb_link: "http://test1.keepsayk.com//images/album_default.jpg",
    featured_main_link: "http://test1.keepsayk.com/img/album_default.png",
    feat_img_type: "image",
    public: "0",
    default_album: "",
    owner_fname: "Mike",
    owner_lname: "Rose",
    owner_id: "102",
    recent_media: false,
    last_media_added_date: false,
    tags: [ ],
    circles: [],
    media: [ ],
    image_count: 0,
    video_count: 0,
    text_count: 0,
    audio_count: 0,
    comments: [ ],
    scrapbook: [ ]
  },
  {
    id: "336",
    title: "Bull",
    description: "",
    location: "",
    date_created: "1353420585",
    date_modified: "1353420585",
    featured_image: "album_default.png",
    featured_thumb_link: "http://test1.keepsayk.com//images/album_default.jpg",
    featured_main_link: "http://test1.keepsayk.com/img/album_default.png",
    feat_img_type: "image",
    public: "0",
    default_album: "",
    owner_fname: "Mike",
    owner_lname: "Rose",
    owner_id: "102",
    recent_media: false,
    last_media_added_date: false,
    tags: [ ],
    circles: [],
    media: [ ],
    image_count: 0,
    video_count: 0,
    text_count: 0,
    audio_count: 0,
    comments: [ ],
    scrapbook: [ ]
  },
  ...
]

下面是我在App Delegate中的代码:

代码语言:javascript
复制
// restkit object manager
    _objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://test1.keepsayk.com"]];
    [AFNetworkActivityIndicatorManager sharedManager].enabled = YES;

// restkit object store
    _objectManager.managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:[self managedObjectModel]];
    [_objectManager.managedObjectStore createPersistentStoreCoordinator];
    [_objectManager.managedObjectStore createManagedObjectContexts];

// setup album object
RKEntityMapping *albumEntityMapping = [RKEntityMapping mappingForEntityForName:@"KeepsaykAlbum" inManagedObjectStore:_objectManager.managedObjectStore];
    albumEntityMapping.identificationAttributes = @[@"identifier"];
    [albumEntityMapping addAttributeMappingsFromDictionary:@{ @"id" : @"identifier", @"title" : @"keepsaykTitle", @"description" : @"keepsaykDescription", @"date_created" : @"dateCreated", @"date_modified" : @"dateModified", @"featured_thumb_link" : @"featuredImageThumbLink", @"featured_main_link" : @"featuredImageLink", @"public" : @"isPublic", @"default_album" : @"isDefaultAlbum", @"owner_fname" : @"ownerFirstName", @"owner_lname" : @"ownerLastName", @"owner_id" : @"ownerIdentifier", @"last_media_added_date" : @"dateMediaModified", @"image_count" : @"imageCount", @"video_count" : @"videoCount", @"text_count" : @"textCount", @"audio_count" : @"audioCount", @"scrapbook" : @"scrapbookLayouts" }];

    [_objectManager addResponseDescriptor:[RKResponseDescriptor responseDescriptorWithMapping:albumEntityMapping pathPattern:@"albums/display/:userID/:apiKey" keyPath:@"" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]];

我在另一个类中调用get方法-在日志中跟踪资源路径:

代码语言:javascript
复制
- (void)loadObjectsFromResourcePath:(NSString *)resourcePath;
{
    NSLog(@"resource path: %@", resourcePath);

    [RKObjectManager.sharedManager getObjectsAtPath:resourcePath parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
        NSLog(@"mapping result: %@", [mappingResult array]);
        [self stopLoading];
    } failure:^(RKObjectRequestOperation *operation, NSError *error) {
        NSLog(@"error: %@", error);
        [self stopLoading];
    }];
}

以下是我的错误日志:

代码语言:javascript
复制
   2012-12-04 17:48:47.437 Keepsayk Alpha[9036:907] I restkit:RKLog.m:34 RestKit logging initialized...
    2012-12-04 17:48:47.703 Keepsayk Alpha[9036:907] I restkit.support:RKMIMETypeSerialization.m:115 JSON Serialization class 'RKNSJSONSerialization' detected: Registering for MIME Type 'application/json
2012-12-04 17:48:47.696 Keepsayk Alpha[9036:907] resource path: albums/display/102/drrrbSAt6RFLsgHaKiiB6kBIyYRyzxLYinL84Kba
    2012-12-04 17:48:47.708 Keepsayk Alpha[9036:1603] I restkit.network:RKHTTPRequestOperation.m:141 GET 'http://test1.keepsayk.com/albums/display/102/drrrbSAt6RFLsgHaKiiB6kBIyYRyzxLYinL84Kba'
    2012-12-04 17:48:47.711 Keepsayk Alpha[9036:907] error (null), (null)
    2012-12-04 17:48:48.995 Keepsayk Alpha[9036:372f] I restkit.network:RKHTTPRequestOperation.m:158 GET 'http://test1.keepsayk.com/albums/display/102/drrrbSAt6RFLsgHaKiiB6kBIyYRyzxLYinL84Kba' (200)
    2012-12-04 17:48:49.011 Keepsayk Alpha[9036:907] error: Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 "Unable to find any mappings for the given content" UserInfo=0x1d5b7e40 {DetailedErrors=(
    ), NSLocalizedDescription=Unable to find any mappings for the givn content, keyPath=null}
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-12-06 03:33:34

我的资源路径中缺少首字母"/“。

代码语言:javascript
复制
[_objectManager addResponseDescriptor:[RKResponseDescriptor responseDescriptorWithMapping:albumEntityMapping pathPattern:@"/albums/display/:userID/:apiKey" keyPath:@"" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]];
票数 0
EN

Stack Overflow用户

发布于 2012-12-05 11:54:19

将keyPath设置为nil而不是@"“

票数 0
EN

Stack Overflow用户

发布于 2012-12-09 12:29:46

如果任何人仍然收到此错误,请检查您的"/“,以便在组合baseURL和您的路径时,您不会以"www.mybase.com//blah/blah.json”结束。此外,如果您更新到最新的Restkit代码,从2012年12月8日起,您应该会得到一个轻微的修复。Blake已经添加了代码,以便在运行时使用比1001更好的描述性警告。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13714167

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档