我想更改Dictionary中对象的值,但是Dictionary结构很复杂。那是;
<dict>
<key>Content</key>
<array>
<dict>
<key>Description</key>
<string></string>
<key>Duration</key>
<string></string>
<key>Image</key>
<string></string>
</dict>
<dict>
<key>Description</key>
<string></string>
<key>Duration</key>
<string></string>
<key>Image</key>
<string></string>
</dict>
</array>
</dict>
我可以访问一个元素(其中plist文件名为Data)
[Data objectForKey:[[[Data objectForKey:@"Content"]objectAtIndex:selectedIndex]objectForKey:@"Description"]]
如何为此对象设置值?
答案 0 :(得分:0)
您可以使用:
[[[Data objectForKey:@"Content"] objectAtIndex:selectedIndex] setObject:@"foo" forKey:@"Description"];
它将键foo
的字符串Description
设置为索引selectedIndex
的数组,并将其设置为键Contents
的字典。