LoginSignup
1
0

More than 5 years have passed since last update.

MagicalRecord の MR_fetchAllWithDelegate メソッド呼び出し時のクラッシュを回避する

Last updated at Posted at 2018-01-22

概要

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メソッドなどが適切に見えます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0