Our third game is a memory card game where you must flip over sets of cards. Flip over two matching cards and you get a point. Flip over two that don't match and you get a strike. Three strikes and you're out. For this game we persist hi-score data using Apple's Core Data model pattern.
Please refer to the project RecipeCollection01 for full working code of this recipe. For the sake of brevity all game logic has been omitted from the following code.
Setting up our Core Data based recipe requires a number of steps.
First we need to add the CoreData framework. You can do this by right clicking on your project and going to Add > Existing Frameworks and then, under iOS 4.x SDK, select CoreData.framework
.
Create a new folder inside your resources entitled
Data Model
. Inside this folder, create a class entitledHiscore
, which derives fromManagedObject
://Hiscore.h #import <CoreData/CoreData.h> @interface Hiscore : NSManagedObject ...