For the next three recipes, we have three small games that need to have their hi-scores persisted. In this recipe, we see a whack-a-mole game that will use a PLIST file to maintain a list of hi-scores.
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.
Execute the following code:
#import "ActualPath.h" @implementation Ch2_SavingDataPlist -(CCLayer*) runRecipe { [self loadHiScores]; return self; } -(void) loadHiScores { //Our template and file names NSString *templateName = @"whackamole_template.plist"; NSString *fileName = @"whackamole.plist"; //Our dictionary NSMutableDictionary *fileDict; //We get our file path NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectory...