Hello.
I have plist with arrays of dictionaries.
Removing of object looks easy enough:
But problem i met is how to update "sectionList" after object was removed from "items" or after new object was added into "items" so updated data can be saved into plist file.
Thank you for help.
Here is plist example:
I have plist with arrays of dictionaries.
Removing of object looks easy enough:
Code:
NSArray *filePaths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSMutableArray sectionList = [NSMutableArray arrayWithContentsOfFile:[NSString stringWithFormat:@"%@/%@",[filePaths objectAtIndex: 0], @"myplist.plist"]];
NSMutableDictionary *sectionItems = [sectionList objectAtIndex:0];
NSMutableArray *items = [sectionItems objectForKey:@"items"];
[items removeObjectAtIndex:0];
But problem i met is how to update "sectionList" after object was removed from "items" or after new object was added into "items" so updated data can be saved into plist file.
Thank you for help.
Here is plist example:
Code:
<plist version="1.0">
<array>
<dict>
<key>items</key>
<array>
<dict>
<key>id</key>
<string>1</string>
<key>name</key>
<string>item title 1</string>
</dict>
<dict>
<key>id</key>
<string>13</string>
<key>name</key>
<string>item title 2</string>
</dict>
</array>
<key>sectionName</key>
<string>Section A</string>
</dict>
<dict>
<key>items</key>
<array>
<dict>
<key>id</key>
<string>1</string>
<key>name</key>
<string>item title 3</string>
</dict>
<dict>
<key>id</key>
<string>13</string>
<key>name</key>
<string>item title 4</string>
</dict>
<dict>
<key>id</key>
<string>4</string>
<key>name</key>
<string>item title 5</string>
</dict>
<dict>
<key>id</key>
<string>444</string>
<key>name</key>
<string>item title 6</string>
</dict>
</array>
<key>sectionName</key>
<string>Section B</string>
</dict>
<dict>
<key>items</key>
<array>
<dict>
<key>id</key>
<string>1</string>
<key>name</key>
<string>item title 7</string>
</dict>
<dict>
<key>id</key>
<string>13</string>
<key>name</key>
<string>item title 8</string>
</dict>
</array>
<key>sectionName</key>
<string>Section C</string>
</dict>
</array>
</plist>