To save data to PLIST, we will take a look at how to create a high score table and save the data of the highest score achieved by a player.
All the necessary files are already there because whackamole_template.plist
was already added in the last section.
We will create three functions: one to load the high scores, the second to add the high scores, and the third to delete the scores in the file.
The function to load highScore
is as follows. We will create two global variables—hiScores
and hiScore
—of the NSMutableArray
type and int
:
//** saving to PLIST -(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...