Mey,
I'm not sure that I understand your statement about having an empty plist. I assume that you mean that if you read back the plist file that you created, it is null when you print it out. Suggesting that you are writing out an empty file or not reading correct or ...
I further assume that your intent is to replace the existing plist contents by a new plist while keeping the same name.
And caveat emptor - I'm new to Objective C etc. Here is a way to do that which I think you are trying to do.
// Implement viewDidLoad to do additional setup after loading the view,
// typically from a nib.
- (void)viewDidLoad {
NSBundle *bundle = [NSBundle mainBundle];
NSString *plistPath = [bundle pathForResource:@"TmpPList" ofType:@"plist"]; //Not NARC
//NSLog(@"plistPath : %@", plistPath);
//My plist is a simple array, but it could be an array of dictionary objects etc
NSMutableArray *arrayFromPList = [[NSMutableArray alloc] initWithContentsOfFile:plistPath]; //NARC
//NSLog(@"arrayFromPList : %@", arrayFromPList);
//Delete the arrays contents and put new contents
[arrayFromPList removeAllObjects];
//NSLog(@"arrayFromPList : %@", arrayFromPList);
//[arrayFromPList addObjectsFromArray:[NSArray arrayWithObjects:@"A", @"B", "@C", nil]];
//NSLog(@"arrayFromPList : %@", arrayFromPList);
[arrayFromPList setArray:[NSMutableArray arrayWithObjects:@"A", @"B", @"C", @"D", @"E", @"F", nil]];
//NSLog(@"arrayFromPList : %@", arrayFromPList);
/* */
//Write it out to the original file name
[arrayFromPList writeToFile:plistPath atomically:YES];
NSMutableArray *newArray = [[NSMutableArray alloc] initWithContentsOfFile:plistPath]; //NARC
NSLog(@"newArray : %@", newArray);
[arrayFromPList release];
[newArray release];
}