José Joel.
José Joel.

Reputation: 2050

Good use of plist

When It comes to .plist files, it's a bad practice to use them to save data other than user settings ?

For example, using plists to save the data of levels in a videogame, or the prices of an item in a RPG game, etc.

Upvotes: 2

Views: 363

Answers (3)

rpj
rpj

Reputation: 2370

Anytime you can offload logic onto a resource that doesn't need to be recompiled to change behavior of your program, you're doing well for yourself.

Of course, with anything, this practice is best when moderated appropriately, but anytime you're doing something that you see changing frequently or at the whim of individual users, consider offload the logic and data that drives it into a plist.

Finally, considering the phenomenal support AppKit provides for working with plists (in many cases one line of code turns an on-disk file into an in-memory data structure), you'd be hard pressed to find solid justification for using other data storage methods unless you're storing gigabytes of data or doing massive cross-structure queries.

Upvotes: 2

Banjer
Banjer

Reputation: 8300

I'm new to Objective-C and Cocoa Touch, but I just followed this UITableView example which uses a plist file to populate a table with a list of movie titles. Works great. It seems like a simpler solution to me than parsing the xml yourself.

Upvotes: 1

zaph
zaph

Reputation: 112857

Using a plist is fine if you want all the data or the amount of data is small. Also consider NSUserDefaults, they are a real nice wrapper and even support integers without boxing. For large data stores especially where only a portion of the data is needed at any one tine use SQLite or CoreData. Also keep in mind that binary plists are smaller and much faster over a network connection.

Upvotes: 7

Related Questions