I have a very basic question about how to write to a plist. I added a "Here.plist" file to my resources folder. The following is my code:
NSString *path = [[NSBundle mainBundle]pathForResource:@"Here" ofType:@"plist"];
NSArray *array = [[NSArray alloc]initWithObjects:@"First", @"Second", @"Third", nil];
[array writeToFile:path atomically:YES];
"Here.plist" is still empty after executing the code. I even tried using a NSDictionary as follows:
NSDictionary *dict = [[NSDictionary alloc]initWithObjectsAndKeys:@"firstValue", @"First", @"secondValue", @"Second", @"thirdValue", @"Third", nil];
[dict writeToFile:path atomically:YES];
I went through many tutorials and forums but its just not working for me. What am i doing wrong? Losing my head over this.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…