Note that there are some explanatory texts on larger screens.

plurals
  1. POaccess value for key in NSDictionary using different key
    primarykey
    data
    text
    <p>Spent about a week using stackoverflows search but no luck...</p> <p>Here is what I have:</p> <p>1 plist:</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;Name 1&lt;/string&gt; &lt;key&gt;abrev&lt;/key&gt; &lt;string&gt;(HGB, ΗbA)&lt;/string&gt; &lt;key&gt;picture&lt;/key&gt; &lt;string&gt;first.png&lt;/string&gt; &lt;key&gt;pictureHeight&lt;/key&gt; &lt;integer&gt;1686&lt;/integer&gt; &lt;/dict&gt; &lt;dict&gt; &lt;key&gt;name&lt;/key&gt; &lt;string&gt;Name 2&lt;/string&gt; &lt;key&gt;abrev&lt;/key&gt; &lt;string&gt; &lt;/string&gt; &lt;key&gt;picture&lt;/key&gt; &lt;string&gt;second.png&lt;/string&gt; &lt;key&gt;pictureHeight&lt;/key&gt; &lt;string&gt;396&lt;/string&gt; &lt;/dict&gt; &lt;dict&gt; ... &lt;dict&gt; &lt;/array&gt; &lt;/plist&gt; </code></pre> <p>The questions is:<br> How to return values for keys "picture" and "pictureHeight"<br> knowing the value for the key "name".</p> <p>I tried something like this, but failed desperately...</p> <pre><code>//creating an array that contains the plist dictArray = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"table1" ofType:@"plist"]]; //creating an array that contains only the vlaues for key "name" NSMutableArray *temp = [dictArray valueForKey:@"name"]; //searchedData - an NSMutableArray containing the "name" values that //the user searched using the searchbar for (i=0; i&lt;[searchedData count]; ++i) { if ([searchedData containsObject:[temp objectAtIndex:i]]) { [temp removeObjectAtIndex:i]; } } </code></pre> <p>At the end I have an array of values for key "name" and I need to get the "picture" and "pictureHeight" to push all of this information to next view controller...</p> <p>I'm looking for any fresh ideas (or maybe tutorials), because I'm not getting too far with mine...</p>
    singulars
    1. This table or related slice is empty.
    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