我遇到了NSTable
刷新问题......
我更新了DetailViewController表并执行
[self.managedObjectContext save:&error];
当我按下后退按钮时,即使我使用NSNotification
设置重新加载表格,表记录也不会更改。
现在,如果我返回并更新另一条记录,并在第一条更新记录反映之前所做的更改后返回.....
关闭应用程序并重新打开后,所有更改都会反映出来,所以我知道它正在保存,只是没有刷新。
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (managedObjectContext == nil) {
managedObjectContext = [(APLViewController *)[[UIApplication sharedApplication] delegate] managedObjectContext];
}
NSManagedObjectContext *context = managedObjectContext;
NSManagedObjectContext *moc = context;
NSEntityDescription *entityDescription = [NSEntityDescription
entityForName:@"Event" inManagedObjectContext:moc];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setReturnsObjectsAsFaults:NO];
[request setEntity:entityDescription];
NSError *error1 = nil;
NSArray *productArray = @[sortDescriptor];
productArray = [[NSMutableArray alloc] initWithArray:[moc executeFetchRequest:request error:&error1 ]];
NSSortDescriptor *sortAZ = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
NSSortDescriptor *sortZA = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO];
NSArray *sortedArray = [productArray sortedArrayUsingDescriptors:[NSArray arrayWithObjects:sortAZ, nil]];
NSArray *desortedArray = [productArray sortedArrayUsingDescriptors:[NSArray arrayWithObjects:sortZA, nil]];
_products = sortedArray;
[self.tableView reloadData];
}