[SDK]iPhoneアプリ開発初心者質問箱34[touch][iPad]
■ このスレッドは過去ログ倉庫に格納されています
0217名称未設定
2013/09/08(日) 17:52:40.72ID:YiYcIqpE0>eventは、このクラスのインスタンス変数かな?
はい。そうです。
今はEventを取得しています。カスケードで消せますが、挙動はおかしいです。
そして、現在のコードがこちらになります。
- (void)insertNewObject:(id)sender
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
Event *list = [self.fetchedResultsControllerS.fetchedObjects objectAtIndex:appDelegate.sharedToDoIndexPath];
Child *child = [NSEntityDescription insertNewObjectForEntityForName:@"Child"inManagedObjectContext:self.managedObjectContext];
child.Event = list;//event; //Childの関連で設定したEventに今の親をセット
child.name = [NSString stringWithFormat:@"Child%d",[self.childlenArray count]];
[list addChildrenObject:child]; //Data
[_childlenArray addObject:child]; //表示用配列
// Save the context.
NSError *error = nil;
if (![self.managedObjectContext save:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
[appDelegate saveContext];
}
■ このスレッドは過去ログ倉庫に格納されています