I have three different viewControllers and they have tableViews in each. 1) firstViewController : has some boynames (loading from plist file boynames) 2) secondViewController : has some girlnames(loading from plist file girlnames) 3) thirdViewController: has saved favorite names (should load from another plist file favoritenames)
My question is when I am saving the names from my firstViewController/secondViewController by clicking on a button attached to the cells, these saved names show up in the thirdViewController only when I load the application for the first time. Then they stop adding to the thirdViewController. I have written the code in viewWillAppear method in my thirdViewController. Any help will be appreciated.
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Do any additional setup after loading the view, typically from a nib.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths lastObject];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"NamesForThirdView.plist"];
self.userSelectedNamesAndMeaning = [[NSMutableDictionary alloc] initWithContentsOfFile: path];
// self.allSelectedNames = [self.userSelectedNamesAndMeaning allKeys];
NSArray *allNames = [self.userSelectedNamesAndMeaning allKeys];
self.allSelectedNames = [allNames sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];// Got shorted]
[self.tableView reloadData];
}