Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone Objects from NSDictionary PList
    primarykey
    data
    text
    <p>in my app I have a section where I load from a saved plist which has 2 nested dictionaries like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;1&lt;/key&gt; &lt;dict&gt; &lt;key&gt;color&lt;/key&gt; &lt;string&gt;yellow&lt;/string&gt; &lt;key&gt;lang&lt;/key&gt; &lt;string&gt;US&lt;/string&gt; &lt;key&gt;name&lt;/key&gt; &lt;string&gt;Peter&lt;/string&gt; &lt;key&gt;uid&lt;/key&gt; &lt;string&gt;1&lt;/string&gt; &lt;/dict&gt; &lt;key&gt;2&lt;/key&gt; &lt;dict&gt; &lt;key&gt;color&lt;/key&gt; &lt;string&gt;blue&lt;/string&gt; &lt;key&gt;lang&lt;/key&gt; &lt;string&gt;US&lt;/string&gt; &lt;key&gt;name&lt;/key&gt; &lt;string&gt;Josh&lt;/string&gt; &lt;key&gt;uid&lt;/key&gt; &lt;string&gt;2&lt;/string&gt; &lt;/dict&gt; &lt;key&gt;3&lt;/key&gt; &lt;dict&gt; &lt;key&gt;color&lt;/key&gt; &lt;string&gt;red&lt;/string&gt; &lt;key&gt;lang&lt;/key&gt; &lt;string&gt;DE&lt;/string&gt; &lt;key&gt;name&lt;/key&gt; &lt;string&gt;Susan&lt;/string&gt; &lt;key&gt;uid&lt;/key&gt; &lt;string&gt;3&lt;/string&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/plist&gt; </code></pre> <p>Now I want to access string like outer dictionary from key 2, value for inner key color (blue) I tried make 2 loops, and it works for the outer dictionary but I can't access the inner </p> <pre><code>NSMutableDictionary *savedData = [NSMutableDictionary dictionaryWithContentsOfFile:path]; // This contains all data from plist for (int x=0; x&lt;[savedData count]; x++) { NSString *itemNumber = [NSString stringWithFormat:@"%d", x+1]; //This prints out the correct inner dictionary NSLog(@"item#%@: %@",itemNumber,[savedData objectForKey:itemNumber]); for (NSDictionary *dict in [savedData objectForKey:itemNumber]) { //prints out color, lang, uid, but no key-value pairs NSLog(@"dict: %@",dict); } } </code></pre> <p>I'd like to know how to directly access key value pairs inside the inner dictionary, could anyone give me a kick in the right direction, please?</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