0

我想更改字典中对象的值,但是字典结构很复杂。那是;

<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 objectForKey:[[[Data objectForKey:@"Content"]objectAtIndex:selectedIndex]objectForKey:@"Description"]]

如何设置此对象的值?

4

1 回答 1

0

你可以使用这个:

[[[Data objectForKey:@"Content"] objectAtIndex:selectedIndex] setObject:@"foo" forKey:@"Description"];

foo它将键的字符串设置为带有键的字典Description索引处的数组。selectedIndexContents

于 2013-04-28T11:00:08.007 回答