すべての のテーブル ビューがあり、いずれentities
かを選択すると、 が表示されdetail view
ます。にdetail view
編集がありますbarbuttonitem
。選択すると、以下のコードが実行されます。テーブルビューはviewdidappearでリロードされ、名の変更を検出しますが、シミュレーターを閉じて再度開くと、以前の値が表示されます。何か不足していますか?
-(void)doneEditing{
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
_managedObjectContext = [appDelegate managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:@"Athlete" inManagedObjectContext:_managedObjectContext]];
NSError *error = nil;
NSArray *results = [_managedObjectContext executeFetchRequest:request error:&error];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"first == %@", _athleteFirst];
[request setPredicate:predicate];
Athlete *currentAthlete = [results objectAtIndex:0];
currentAthlete.first = _firstDetailTextField.text;
[self.navigationItem setRightBarButtonItem:nil animated:YES];
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
UIBarButtonItem *allAthletesButton=[[UIBarButtonItem alloc] initWithTitle:@"All Athletes" style:UIBarButtonItemStylePlain target:self action:@selector(popACapInYoViewController)];
UIBarButtonItem *editButton=[[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleDone target:self action:@selector(editAthlete)];
[self.navigationItem setRightBarButtonItem:editButton animated:YES];
[self.navigationItem setLeftBarButtonItem:allAthletesButton animated:YES];
[self.view endEditing:YES];
}