2012年3月7日水曜日

Core Data 関連エラー


exception=+entityForName: could not locate an NSManagedObjectModel for entity name '<entityName>'
  • NSEntityDescriptionのinsertNewObjectForEntityForNameメソッドのmanagedObjectContextパラメータがnilのときに発生します。
  • UIViewControllerにmanagementContextという名前のプロパティーがあり、これがnilのときにUIViewControllerでself.managementContext を使ってNSManagedObjectオブジェクトを作ろうとすると、同じ理由で発生します。
  • コーディングミスなので特殊なケースですが、managedObjectContextを作るときにsetPersistentStoreCoordinatorの行が抜けているとこのエラーが発生します。
    [managedObjectContext setPersistentStoreCoordinator:cordinator];
CoreData 1570 Error Code / Operation could not be completed.
不正なデータをセット、あるいは必須項目にnilをセットした場合に発生します。
attributeのプロパティーでoptionalのチェックが外れている場合は必須項目となります。
エラーメッセージの中の”NSValidationErrorKey”に、どの項目がエラーかわかります。

参照: http://stackoverflow.com/questions/7862191/coredata-1570-error-code。


'+entityForName: could not locate an entity named 'WrongName' in this model.'
Entityの名前がCore Date Editorで設定した名前と異なっている場合に発生します。

persistentStoreCoordinator: Error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.) ......,
reason=The model used to open the store is incompatible with the one used to create the store ......
ModelのAttributeの追加/削除等があった場合に発生します。マイグレーションを検討すべきですが、てっとり早い対処方法はアプリケーションの削除/再インストールです。


...Model.xcdatamodeld/Model 3.xcdatamodel:Person.addr3: error: Person.addr3 must have a defined type
...error: Compilation failed for data model at path '...'
Core DataのEntityのAttributeの型が未設定の場合に発生します。
当該Attribute(この場合はPerson.addr3)のTypeを設定します。

0 件のコメント: