Note that there are some explanatory texts on larger screens.

plurals
  1. POhow do I access a specific key vale within an array of dictionaries
    primarykey
    data
    text
    <p>How do I access a single key value from a specific key?</p> <p>I am using an NSArray of NSDictionary with a plist source as shown below;</p> <pre><code>&lt;plist version="1.0"&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;name&lt;/key&gt; &lt;string&gt;item name&lt;/string&gt; &lt;key&gt;level&lt;/key&gt; &lt;integer&gt;3&lt;/integer&gt; // range is 1 .. 7 &lt;key&gt;Stage1&lt;/key&gt; &lt;string&gt;Text for Stage 1&lt;/string&gt; &lt;key&gt;Stage2&lt;/key&gt; &lt;string&gt;Text for Stage 2&lt;/string&gt; &lt;key&gt;Stage3&lt;/key&gt; &lt;string&gt;Text for Stage 3&lt;/string&gt; &lt;key&gt;Stage4&lt;/key&gt; &lt;string&gt;Text for Stage 4&lt;/string&gt; &lt;key&gt;Stage5&lt;/key&gt; &lt;string&gt;Text for Stage 5&lt;/string&gt; &lt;key&gt;Stage6&lt;/key&gt; &lt;string&gt;Text for Stage 6&lt;/string&gt; &lt;key&gt;Stage7&lt;/key&gt; &lt;string&gt;Text for Stage 7&lt;/string&gt; &lt;/dict&gt; // more dictionaries follow </code></pre> <p>I can view the whole dictionary by doing the following:</p> <pre><code>NSNumber *helps = [myArray objectAtIndex:[pickerView selectedRowInComponent:0]]; notesLabel.text = [NSString stringWithFormat:@"%@", helps]; </code></pre> <p>Your help is greatly appreciated ... I am such a noob.</p> <p>Till, thanks for the help! I was able to add: </p> <pre><code>NSDictionary *dictionary = [foodArray objectAtIndex:[pickerView selectedRowInComponent:0]]; notesLabel.text = (@"stage is: %@", [dictionary objectForKey:[NSString stringWithFormat:@"%@", stage]]); </code></pre> <p>Which gives me exactly what I was missing. :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload