Alright, I am using a plist to load data into a tableview. I have all of that working just fine. I have also successfully copied the plist from the bundle to the documents folder.
I need some help figuring out the code needed to add an item to the plist. Here is the structure of the plist thus far
NSDictionary (ROOT)
- NSArray (The Array I am Accessing
- Item 0 (DICTIONARY)
- Name - String
- Category - String
- Image - String
- Item 1 (DICTIONARY)
- Name - String
- Category - String
- Image - String
- Item 2 (DICTIONARY)
- Name - String
- Category - String
- Image - String
- Item 3
(THIS IS WHAT I WANT TO ADD)
- Name - String
- Category - String
- Image - String
I am not sure how to edit the plist. Here is the code i have so far (which is pretty much a hacking together of crap I searched for on the internet)
NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory,NSUserDomainMask, YES) objectAtIndex:0];
NSString *path = [docsDir stringByAppendingPathComponent:@"Fav.plist"]; //3
NSMutableDictionary *favPlist = [[NSMutableDictionary alloc] initWithContentsOfFile: path];
//here add elements to data file and write data to file
NSDictionary *newDictionary = [[[NSDictionary alloc] init] autorelease];
newDictionary = [NSDictionary dictionaryWithObjectsAndKeys:trickTitle,@"Title", trickDifficulty, @"Difficulty",trickDescription, @"Description", posterLocation, @"Poster", videoLocation, @"Play", nil];
[favPlist setObject:newDictionary forKey:@"Fav"];
[favPlist writeToFile

ath atomically:YES];
[favPlist release];