we need to be able to read in the contents of an existing plist file then add to the array / dictionary then write this new data to the plist file. The stricture is simple.
You do it like this:
// Get current content.
NSDictionary *oldContent = [NSDictionary dictionaryWithContentsOfFile:plistPath];
// Make a mutable copy.
NSMutableDictionary *newContent = [[oldContent mutableCopy] autorelease];
// Add new stuff.
[newContent setObject:newObject forKey:newKey];
// Now, write the plist:
[newContent writeToFile:plistPath atomically:YES];
There is no need to use NSPropertyListSerialization
at all here.
You have a Dictionary to begin with,
124818240124810284.JPG //[valueForKey: 124818240124810284.JPG]
item 0 String Some Attribute 1 //[valueForKey:124818240124810284.JPG] valueForKey:Item 0];
item 1 String Some Attribute 2 //[valueForKey:124818240124810284.JPG] valueForKey:Item 1];
354273577823597297.JPG //[valueForKey: 354273577823597297.JPG]
item 0 String Some Attribute 1 //[valueForKey: 354273577823597297.JPG] valueForKey:Item 0];
item 1 String Some Attribute 2 //[valueForKey: 354273577823597297.JPG] valueForKey:Item 1;
And so on.....To add to it create a new dictionary with your new value/key pairs :
NSMutableDictionary *newAttributes = [[NSMutableDictionary alloc]initWithObjectsAndKeys:@"Attribute 0",@"Item 0",nil];
Make a new dictionary:
NSMutableDictionary *newEntry = [[NSMutableDictionary alloc]initWithObjectsAndKeys:newAttributes,@"xxxxx.jpg", nil];//Makes a new dictionary
Or to append the data to the existing dictionary:
[dictionaryToAppend setValue:newAttribues ForKey:xxxxx.jpg"];