hachinoBlog

hachinobuのエンジニアライフ

Coredataの読み込み先とかまとめ

CoreDataはモデルファイルと読み込み先のファイルを指定してあげることで
複数のDBもしくは複数のデータファイルから読み込みを行うことができる。
NSPersistentStoreCoordinatorでどのモデルファイル、どのファイルから読み込むのか指定している。

exception 'NSInvalidArgumentException', reason: 'Illegal attempt to establish a
relationship 'テーブル名' between objects in different contexts
上のエラーはNSManagedObjectが相違しているから。
同一のNSManagedObjectで処理してあげないといけない。

参考URL
http://stackoverflow.com/questions/1554623/illegal-attempt-to-establish-a-relationship-xyz-between-objects-in-different-c