开发者

How to change a value inside a dictionary in an array that's inside a dictionary?

I have a plist dictionary with several arrays where each have different number of items. These items are dictionaries too. So basically it looks like this:

  • Root dictionary
    • names array
    • places array
      • Item 0 dictionary
      • Item 1 dictionary
        • placeName string: "House"
        • description string: "My House"
        • height number: 10
      • Item 2 dictionary
      • ...
    • colors array
    • ...

I want to find the best way to change a value inside one of these arrays (placeName, description, height).

The plist is part of the resources, so I call it in like th开发者_JS百科is:

[[NSMutableDictionary alloc] initFromName:@"mydefaults.plist"];

I've seen the setValue:forKey methods, but it looks like I'm heading into a mess. I don't think I should have to be setting the whole complete array if it's just one value.

So, which is the best way?


How about something along the lines of

[[[plistDictionary objectForKey:@"places"] objectAtIndex:1] setValue:@"Another house" forKey:@"placeName"]

if the "internal" arrays and dictionaries are indeed mutable.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜