开发者

How do I query Core Data to return the nearest XX objects to me?

I have populated a Core Data database and need to query it based upon my users location. We use similar code at the backend of a webservice a开发者_JAVA百科s a UDF and return the distance as a column, but we now have a requirement to cache some of this data for offline use.

I know CLLocation has a distanceTo method but is this going to be efficient when parsing a few thousand rows of data?


A few thousand rows isn't a huge amount of data. Make sure you design your CoreData schema such that it can load the objects with the location information without also loading tons of other data (put any large blocks of data into their own objects and let it load them lazily).

When you start getting beyond a few thousand, though, you might need to go to a different local data structure, such as some library that implements an R-Tree or range searches.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜