NSSortDescriptor with to-many relationship

前端 未结 1 653
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-11 06:52

I have a Parent entity which has to-many Child. If I order the Parent fetch with a property (e.g. name), everything works fine. But if I try this:

NSSortDesc         


        
1条回答
  •  独厮守ぢ
    2020-12-11 07:26

    Assuming you are using a sqlite store; you cannot sort by @count because it is resolved at the "object" level whereas the NSSortDescriptor on the NSFetchRequest is resolved at the database level. Therefore, as you guessed, you would need to create a counting property to sort by.

    If you are using a binary or in-memory store type then count should work fine since they are only accessed as objects.

    0 讨论(0)
提交回复
热议问题