maxedison
maxedison

Reputation: 17553

How to store all this pre-created data?

I'm currently storing some commonly used arrays and dictionaries in .plist files. However, duplicate data DOES exist in these files. Instead, I'd like to be able to implement something more along the lines of a relational database in order to store references to data rather than repeat the data. I'm guessing there is no way to do this with plist files, but CoreData seems like overkill for this.

One thought I had was to subclass NSArray and NSDictionary in order to provide default values. Rather than loading a dictionary from a plist file, whatever object needs the data would instead just instantiate one of these NSArray/NSDictionary subclasses (which would in turn instantiate others of these subclasses when necessary -- this is how the "relational database" functionality would be achieved). Is that a sound approach, or is there some other tool in iOS or Xcode that I'm not aware of and would make this simple?

Upvotes: 0

Views: 116

Answers (2)

elaydin
elaydin

Reputation: 31

I've used SQLite in situations like these.
Here's a video of everything I've learned about using SQLite in apps (Stanford class) I assume there are plenty of other examples available.

The nice thing is, you can use a variety of tools/plugins to enter or manage your data. Then just make whatever queries of you need to in your code.

Upvotes: 1

sosborn
sosborn

Reputation: 14694

If the data will never change, then I would stick with your current approach, unless you are having problems with performance. Another option is to move everything to SQLite and then use a wrapper like FMDB.

If the data is initial data that will be changing over the lifetime of the app (you need persistence between launches) then I would make the switch to CoreData.

No matter what you do I would stay away from subclassing NSArray/NSDictionary. You can provide default values without subclassing.

Upvotes: 1

Related Questions