概要
MagicalRecord
利用時、特定のモデルのオブジェクトを全部取得したい時
MR_fetchAllWithDelegate
メソッドを呼び出すと下記のようなエラーが出てクラッシュする。
log
'An instance of NSFetchedResultsController requires a fetch request with sort descriptors'
原因
MR_fetchAllWithDelegate
内部でMR_requestAllInContext
を呼び出している。
ここで作成されたNSFetchRequest
オブジェクトを利用して全取得を行おうとしている。
しかし、ここで作成されたNSFetchRequest
オブエジェクトはsortDescriptor
が設定されておらず、これを利用すると必ず落ちる。
どうやらMagicalRecord内のバグのようです。
参考
https://github.com/magicalpanda/MagicalRecord/issues/348
解決
オブジェクトの全取得をしたいのであれば、別の方法を試すほうが良さそう。
MR_findAllInContext
メソッドなどが適切に見えます。