I'm creating a simple "find one of our locations" app for iOS 4, for which I have a list of >70 places, complete with addresses, business hours, etc. Is it better to put all of this data in one large plist or many small ones?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
Core Data or sqlite would probably be best, but between the two options you mention, I'd favor one large plist over many small ones. Maintaining and tracking 70 files is probably much more error prone than one, and the loading code would be much easier with one also (you can load the whole file into a big NSArray or NSDictionary with only a couple lines of code).
Premature optimization is the root of all evil. Do whatever is simpler/easier (depends on what form the data is in now), and then see how it performs. Even 70 items probably wouldn't take up much memory (assuming it's all text and no images), and I wouldn't be shocked if a naïve linear search is fast enough when you're finding the closest location. And if it isn't fast enough, a binary search probably is. (In fact, if you stored all 70 in an array, then created two "index" arrays that are just the indexes of the first array sorted by latitude and longitude respectively, you would probably perform just as well as a full-blown SQLite database.)