2012-07-10 57 views
0

我想更改字典中對象的值,但字典結構很複雜。那是;在複雜的plist文件中設置對象的值

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

如何設置的值,在此對象的元素?

回答

0

您可以使用此:

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

它設置字符串foo爲重點Description到數組索引selectedIndex到字典與關鍵Contents