我有一個由用戶在我的應用程序中填充的plist。我試圖在UITableView中顯示該plist的內容,並且直到應用程序重新啓動後纔會顯示,這意味着它不會更新。這裏是我有:當我的plist更新時試圖重新加載一個UItableview?
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
NSString *path = [[NSBundle mainBundle] pathForResource:@"foodList" ofType:@"plist"];
arrayFood = [[NSMutableArray alloc]initWithContentsOfFile:path];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView reloadData];
NSString *path = [[NSBundle mainBundle] pathForResource:@"foodList" ofType:@"plist"];
arrayFood = [[NSMutableArray alloc]initWithContentsOfFile:path];
}
在此先感謝!
表示您希望將表格的內容更改爲plist u更新? –
無論您何時更新您的plist,都可以重新載入表格。 –