菜鸟教程小白 发表于 2022-12-12 09:18:23

ios - 为什么objectForKey : @"" returning (null)?


                                            <p><p>我整天都在为此苦苦挣扎,不知道我做错了什么。我有一个 <code>NSDictionary</code></p>

<pre><code>NSDictionary*dict=;
</code></pre>

<p>当我 <code>NSLog(@"%@",dict);</code> 它返回以下...</p>

<pre><code>{
nodeAttributeArray =   (
            {
      attributeName = class;
      nodeContent = style1;
    }
);
nodeChildArray =   (
            {
      nodeContent = &#34;Number of Patrons Using Facility: 151&#34;;
      nodeName = text;
    },
            {
      nodeName = br;
    },
            {
      nodeContent = &#34;
\n      Room Occupancy: 210 &#34;;
      nodeName = text;
    },
            {
      nodeName = br;
    },
            {
      nodeContent = &#34;
\n      Current Wait: 0 minutes &#34;;
      nodeName = text;
    }
);
nodeName = p;
}
</code></pre>

<p>但是,当我输入以下代码时...</p>

<pre><code>NSArray*dictArray=;
NSLog(@&#34;%@&#34;,dictArray);
</code></pre>

<p>它返回 <code>null</code> 。我正在尝试从 <code>NodeChildArray</code> 键中提取 nodeContent,但我什至无法提取该键。不知道为什么它一直返回 null</p>

<p>修订</p>

<p>这是我正在执行的确切行...</p>

<pre><code>//some HTML parsing before this
NSArray *tutorialsNodes = [tutorialsParser   
searchWithXPathQuery:tutorialsXpathQueryString];

NSDictionary*dict=;

NSArray*dictArray=;

NSLog(@&#34;%@&#34;,dictArray);
</code></pre>

<p>两次返回<code>null</code></p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>根据您的评论:</p>

<blockquote>
<p>The app crashed when I print ...I get the following
errror *** Terminating app due to uncaught exception
&#39;NSInvalidArgumentException&#39;, reason: &#39;-:
unrecognized selector sent to instanc</p>
</blockquote>

<p>这就是为什么您无法根据 Key 提取值(value)的原因。您正在从字典中获取 THppleElement。您需要再次 <a href="https://stackoverflow.com/questions/2860941/tfhppleelement-hpple-parsing-html-on-iphone" rel="noreferrer noopener nofollow">parse this TFHppleElement to NSDictionary</a>获取所需的 valueForKey。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 为什么objectForKey : @&#34;&#34; returning (null)?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/15149305/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/15149305/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 为什么objectForKey : @&#34;&#34; returning (null)?