gpt4 book ai didi

objective-c - Restkit - didLoadObjects 正在接收一个空数组

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:53:18 27 4
gpt4 key购买 nike

我已经阅读了每篇文章并浏览了教程,但我无法弄清楚为什么“对象”数组是空的。在 didLoadResponse 方法中,我能够在日志中看到 [response bodyAsString]。下面是我正在加载的 xml 和我用于对象映射的代码。任何帮助将不胜感激。

<?xml version="1.0" encoding="UTF-8"?>  <articles> 
<article>
<title>This is a test title for article 1</title>
<link>google</link>
<description>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed quis bibendum eros. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</description>
<publicationDate>23 Feb 2012</publicationDate>
</article> </articles>


RKObjectMapping* articleMapping = [RKObjectMapping mappingForClass:[Article class]];
[articleMapping mapKeyPath:@"title" toAttribute:@"title"];
[articleMapping mapKeyPath:@"link" toAttribute:@"link"];
[articleMapping mapKeyPath:@"description" toAttribute:@"description"];
[articleMapping mapKeyPath:@"publicationDate" toAttribute:@"publicationDate"];

//I changed my BaseURL for this post
RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:@"myserverpath"];
[manager.mappingProvider setMapping:articleMapping forKeyPath:@"articles.article"];
[manager loadObjectsAtResourcePath:@"/restkit/restkit_test.xml" objectMapping:articleMapping delegate:self];

最佳答案

你试过..

// RKLogLevelDebug or so..
RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);

..查看无法完成映射的原因?

您也可以尝试使用 rootKeyPath :

articleMapping.rootKeyPath = @"articles.article";

关于objective-c - Restkit - didLoadObjects 正在接收一个空数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9437151/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com