作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
大家好,我花了几个小时试图解决这个问题。长话短说,我试图从数组中的 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/
我是一名优秀的程序员,十分优秀!