iOS 4 won't load new property list
Have created a new property list, and deleted the original .plist (same filename). Deleted old file and moved to trash. Dropped in new file of same name.
When app opened in Simulator, the old .plist file loaded. What's going on?
Here is my code in the implementation file:
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to display an Edit button in 开发者_StackOverflow中文版the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
NSString *path = [[NSBundle mainBundle] pathForResource:@"DrinkArray" ofType:@"plist"];
NSMutableArray *tmpArray = [[NSMutableArray alloc]
initWithContentsOfFile:path];
self.drinks = tmpArray;
[tmpArray release];
}
Open your plist file with a text editor. If root is set to dict, change it to array, also remember to change the bottom bracket at the end of the file. Save and rerun and it should be ok.
An alternative is to use an NSMutableDictionary since the plist root probably is already a dictionary.
I had the same problem and the above worked.
精彩评论