Time for action – using the text field
What's the purpose of the highscores table if you can't beat any of the highscores? Let's change that and replace the test data with the actual highscores. To do this, we're going to need the player to enter their name when they beat a highscore:
- Create a new Objective-C class in the
Common
group. Name the classHighscoreManager
and make it a subclass ofNSObject
. - Open the
HighscoreManager.h
file and replace its contents with the following code:#import "GameStats.h" #define kMaxHighscores 5 @interface HighscoreManager: NSObject -(NSArray *)getHighScores; -(BOOL)isHighscore:(int)score; -(void)addHighScore:(GameStats *)newHighscore; +(HighscoreManager *)sharedHighscoreManager; @end
- Then, open the
HighscoreManager.h
file and replace its contents with the following code:#import "HighscoreManager.h" @implementation HighscoreManager { NSMutableArray *_highScores; } -(instancetype)init { if (self...