私はストーリーボードと共にコアデータを使用しています。私は1 UITableView
と1 UIViewController
です。 entireをエンティティに追加すると、コンテキスト(データベース)に追加されますが、私が戻ったときにテーブルビューに反映されません。私は再び私のアプリを実行しなければならないと私は私の追加エントリを見ることができる鶏。これは私が新しいオブジェクトを追加する方法である:私のUITableViewに追加されたエントリを反映するには?
- (void)viewDidLoad
{
[super viewDidLoad];
myAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.managedObjectContext = myAppDelegate.sharedManagedObjectContext;
NSFetchRequest *personListRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *personEntity = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:managedObjectContext];
[personListRequest setEntity:personEntity];
NSError *personListRequestError;
NSArray *personsList = [self.managedObjectContext executeFetchRequest:personListRequest error:&personListRequestError];
for(Person *thisPerson in personsList) {
NSLog(@"First name is %@", thisPerson.firstName);
NSLog(@"First name is %@", thisPerson.lastName);
}
NSLog(@"the contents of array are %@",personsList);
personArray = [[NSMutableArray alloc] initWithArray:personsList];
}
私は私のエントリは、私はそれらを追加するとき、私はそれらを見るために、再び私のアプリを実行したくない、私のテーブルで更新することにしたいです。
をviewDidLoad:[self.tableview reloadData]の下部に表示してください。 –
私は新しいデータベースをリロードしなければならないデータをリロードしたくありません。 – newstar7867