views:

124

answers:

1

I'm working on a game where really the only game part is (at least right now) that the user can unlock achievements as she does various things throughout the game. I have a database that can keep track of certain user actions and record how many times a user does something but I'm having trouble figuring out the best way to architect the app so that I have to do the least amount of work. Kind of suck with the timing because gamecenter is not ready and it seems like openfeint is changing gears, but maybe I'm wrong. I'd prefer to do everything "in house" if it is not too ridiculous. looking for suggestions.

One of the parts I'm having the most trouble figuring out is how to manage the state of all the achievements. NSuserdefaults vs. core data vs. a flat data file.

Also is there anyway to send a notification if a core data field reaches a certain amount?

Thanks,

Nick

+1  A: 

Are you keeping the achievements on the device only, or also on the server? On the device, there is no reason not to use Core Data.

Using Core Data, you could use KVO on your model properties to monitor when certain values reach a new achievements.

Martin Cote
just on the device.
nickthedude
added to question above: Also is there anyway to send a notification if a core data field reaches a certain amount?
nickthedude
KVO is your friend. It is easy to monitor a Core Data field using that.
Martin Cote
sweet pimpin! thanks Martin!
nickthedude
let me ask you this, do you have to register to be an observer each time the app launches?
nickthedude
Yes. The observer won't persist (not automatically at least), so you have to register yourself at startup.
Martin Cote
Any way you could give some code examples of using KVO with core data to round this answer out? specifically attaching the observer to a specific property of a managed object model instance. There is very little out there in the way of resources for using KVO and core data together and it sounds like it could be a really powerful combo. Thanks again Martin! --Nick
nickthedude