Core Data を使用して保存されたオブジェクトのリストを取得しようとしています。プロジェクトの作成時に Xcode によって行われたデフォルトの設定は変更されていません。実際のデータ ストアには項目があり、エンティティTransaction
は保存時に正常に動作しますが、次のコードを実行すると:
NSManagedObjectContext * context = [[NSApp delegate] managedObjectModel];
NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription * entity = [NSEntityDescription
entityForName:@"Transaction"
inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSError * error = nil;
NSArray * transactionList = [context executeFetchRequest:fetchRequest error:&error];
if (&error != nil) {
[Utility showMessage:error.description asError:YES];
} else {
[Utility showMessage:[NSString stringWithFormat: @"Items: %@", transactionList.count] asError:NO];
}
オブジェクトを作成しようとすると、次のエラーが表示されentity
ます。
[NSManagedObjectModel persistentStoreCoordinator]: 認識できないセレクタがインスタンスに送信されました
何が欠けているか、またはエラーの原因を確認するにはどうすればよいですか?
Footnotes
-単純にボックスUtility
を生成する静的クラスです。
-このチュートリアルを使用して、コードがどのように機能するかを理解しようとしていますNSAlert