3つのコントローラを持つコンテナビューコントローラを作成しました。これは2番目のビューコントローラ(VC)です。私が最初にVC第二と第二VCの代わりに、最初のVCを移動したときに、このエラーがあります:'NSInvalidArgumentException'を解決する方法、 '+ entityForName:nilは法的なNSManagedObjectContextではありません
「NSInvalidArgumentException」、理由:「+ entityForName:nilのエンティティ名を検索法的NSManagedObjectContextパラメータではありません[プログラム] 「
NSEntityDescription *entitydesc = [NSEntityDescription entityForName:@"Programs" inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc]init];
request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"programId" ascending:YES]];
request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"startTime" ascending:NO], [NSSortDescriptor sortDescriptorWithKey:@"day" ascending:YES]];
私のビューコントローラコード
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
controller1 = [[Home alloc]initWithNibName:@"Home" bundle:nil];
}
else
{
controller1 = [[Home alloc]initWithNibName:@"Home_iPad" bundle:nil];
}
controller1.title = @"Home";
controller1.delegate2 = self;
controller2 = [storyboard instantiateViewControllerWithIdentifier:@"Activity"];
controller2.title = @"Activity";
controller2.delegate = self;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
controller3 = [[League alloc] initWithNibName:@"League" bundle:nil];
}
else
{
controller3 = [[League alloc] initWithNibName:@"League_iPad" bundle:nil];
}
controller3.title = @"League";
// controller4 = [[Messages alloc] initWithNibName:@"Messages" bundle:nil];
// controller4.title = @"Message";
NSArray *controllerArray = @[ controller2,controller1, controller3];
あなたのエンティティ名が正確に "プログラム"かどうかを確認できますか? (NSManagedObjectContext * - – Arun
はい、私のエンティティ名が私のメインビューコントローラやビューコントローラoのプログラム – user6584316