Slinky
Slinky

Reputation: 5832

iOS Design Pattern for App Data Updating

I am working on an iOS app that is basically a "tip of the day" thing. There are about 3500 tips already in the database. Every day, there will be a new tip added.

My idea is to store the 3500 tips in an NSMutableArray or NSMutableDictionary. Since the source data will grow daily, I'll need a pattern to keep the data in the app's data structure in sync as seamlessly as possible.

Something like this, on app launch?

Am I on the right track here? NSMutableArray VS. NSMutableDictionary?

Thanks!

What design pattern fits this best?

Upvotes: 0

Views: 275

Answers (1)

vikingosegundo
vikingosegundo

Reputation: 52227

I think the easiest would be, to save a token to the DB every time something in the DB was saved and associate all changed object to it. When the client ask for new data, it passes the last token it got to the server and the server response with the objects associated with the tokens generated since the token that was given by the client.

How you store the data client side is a decision you have to make. But it is not about using NSMutableArray or NSMutableDictionary, but how to save it on the device. I'd suggest you to have a look into CoreData, but also direct SQLite or plist might be possible.

And of course you can use dictionary and arrays at the same time. i.e. You could have a big array with all entries ordered by date and put the same entry objects into a dictionary with keys for the date.

Upvotes: 3

Related Questions