0

I want to change the value of an object in a Dictionary, however, the Dictionary structure is complex. That is;

<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>

I can access an element with (Where the plist file is called Data)

[Data objectForKey:[[[Data objectForKey:@"Content"]objectAtIndex:selectedIndex]objectForKey:@"Description"]]

How do I set the value at for this object?

4

1 に答える 1

0

これを使用できます:

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

fooキーの文字列をDescription配列のインデックスに設定し、キーを使用selectedIndexしてディクショナリに入力しますContents

于 2013-04-28T11:00:08.007 に答える