开发者

MUST I provide an NSSortDescriptor in core data when doing a fetch request?

I wonder if I could just execute a NSFetchRequest with just the Entity and nothing else. However, it seems to work with no errors, but since I've never seen anyone doing that, I wonder if there are any bad drawbacks in doing this. The documentation doesn't say 开发者_开发百科if there's any default value used instead when I provide no NSSortDescriptor.


It will work, but your objects will come back in an unpredictable order. If you really just need every instance of a single entity without regard to ordering, then yes, it will work the way you want.


Yes, NSSortDescriptor is optional as is the array of NSPredicate objects. As Alex says, you will get responses back in an unknown order, however you may wish to do this for a couple of reasons. You may wish to simply check whether you have at least 1 of a particular NSManagedObject or more typically if you are simply processing data (and not displaying it) then you simply need to enumerate across every object. In this case the order may not be relevant.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜