我有三个不同的viewControllers,每个都有tableViews。 1)firstViewController:有一些boynames(从plist文件boynames加载) 2)secondViewController:有一些女孩名(从plist文件中输入女孩名) 3)thirdViewController:保存了喜欢的名字(应该从另一个plist文件加载名称加载)
我的问题是,当我通过单击附加到单元格的按钮从我的firstViewController / secondViewController保存名称时,这些保存的名称仅在我第一次加载应用程序时显示在thirdViewController中。然后他们停止添加到thirdViewController。我已经在我的thirdViewController中的viewWillAppear方法中编写了代码。任何帮助将不胜感激。
- (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];
}