gpt4 book ai didi

iphone - 如何将 "nodeContent"埋入数组中

转载 作者:行者123 更新时间:2023-12-03 20:08:40 24 4
gpt4 key购买 nike

大家好,我花了几个小时试图解决这个问题。长话短说,我试图从数组中的 nodeContent 获取值。当我有一个断点和一个数组的“打印描述”时,这就是它吐出的内容。我的问题是,如何获取下面列出的隐藏“nodeContent”的内容?如果可能的话,我想将其返回到字符串中?

NSArray 打印输出到控制台:

{
nodeAttributeArray = (
{
attributeName = class;
nodeContent = g;
}
);
nodeChildArray = (
{
nodeAttributeArray = (
{
attributeName = href;
nodeContent = "/site.aspx?s=23RBHJz4%2bck%3";
}
);
nodeChildArray = (
{
nodeContent = update;
nodeName = div;
}
);
nodeContent = "3.49"; //THIS IS THE VALUE I WANT
nodeName = a;
}
);
nodeContent = "";
nodeName = th;
}

我可以将它作为字符串返回吗?

NSString * value = [code]??

我非常感谢任何帮助!

最佳答案

您可以修改 TFHppleElement 以返回子对象。

TFHppleElement.h中:

@interface TFHppleElement : NSObject
[..]

- (NSArray*)children
@end

TFHppleElement.m中:

NSString * const TFHppleNodeChildArrayKey     = @"nodeChildArray";

@implementation TFHppleElement
[..]
- (NSArray*)children {
[node objectForKey:TFHppleNodeChildArrayKey];
}
[..]
@end

现在你可以像这样得到它,

NSString *value = [[[object children] objectAtIndex:0] content];

原始答案

打印输出表明它是一个基于花括号的字典对象。您可能想查看this 。对于这种情况,您应该能够使用以下方法获得您的值:

NSString *value = [[object valueForKeyPath:@"nodeChildArray.nodeContent"] objectAtIndex:0];

关于iphone - 如何将 "nodeContent"埋入数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6241520/

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