开发者

Editing one of many dict's in plist file?

On my root view controller (UITableViewController开发者_如何学Python), I've read into NSMutableDictionary the root dict from the plist file and have displayed in the table, keys for all dict's within the root dict. When the user taps on any of the key, I pass the dictionary (again as an NSMutableDictionary) to that key to a new detail view controller where this dictionary is displayed.

Now when a particular detail of this dictionary is edited I would like to update the dictionary object and save to the plist file.

1- I'm not even able to update the NSMutableDictionary object e.g. using its - (void)setObject:(id)anObject forKey:(id)aKey method.

2- Is it possible to read into an NSMutableDictionary a plist file in the order as it is in the plist file because I would want to allow the user to re-arrange their views (hence update plist file accordingly).

XML structure:

<plist version="1.0">
    <dict>
        <key>abc</key>
        <dict><key></key><string></string></dict>
        <key>ijk</key>
        <dict><key></key><string></string></dict>
    </dict>
</plist>

Help will be really appreciated! Thanks Bilal.


To answer part 2 of the question, a dictionary is the wrong data structure to use when you want to maintain a particular ordering of the contents. A dictionary is a key-value structure, not an ordered collection. You may want an NSMutableArray instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜