次のような構造の plist があります。
<dict>
<key>memos</key>
<array>
<dict>
<key>title</key>
<string>First Memo</string>
<key>content</key>
<string>Testing one two three</string>
<key>category</key>
<string>testing</string>
</dict>
<dict>
<key>title</key>
<string>Test</string>
<key>content</key>
<string>This is a test memo.</string>
<key>category</key>
<string>testing</string>
</dict>
</array>
</dict>
私はそれを次のような配列に読み込んでいます:
self.memos = [NSMutableArray array];
NSString *path = [[NSBundle mainBundle] pathForResource:@"Memos" ofType:@"plist"];
NSDictionary *tempDictionary = [NSDictionary dictionaryWithContentsOfFile:path];
NSArray *tempArray = [tempDictionary objectForKey:@"memos"];
for(id dict in tempArray) {
NSString *title = [dict objectForKey:@"title"];
NSString *content = [dict objectForKey:@"content"];
NSString *category = [dict objectForKey:@"category"];
Memo *m = [[Memo alloc] initWithTitle:title content:content category:category];
[self.memos addObject:m];
}
私の質問は、新しいメモ (3 つの文字列の辞書) を plist (具体的には、plist 内のメモ辞書の配列) に追加するにはどうすればよいですか?