Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 4    Views: 59

Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
06/05/13 03:07 PM (12 years ago)

Game Center Code (For BT_ViewController.m) (iOS 6)

Hi All, I have fixed all the warnings in the Game Center code for the BT_ViewController.m file (based on MGoBlue's Tutorial) Here is the code: (You can copy and paste below the @Synthasize statements) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @synthesize gameCenterManager; @synthesize currentScore; @synthesize currentLeaderBoard; @synthesize currentScoreLabel; //Start Game Center //GameCenter View Did Load -(void)viewDidLoad { [super viewDidLoad]; self.currentLeaderBoard = kLeaderboardID; self.currentScore = 0; if ([GameCenterManager isGameCenterAvailable]) { self.gameCenterManager = [[[GameCenterManager alloc] init] autorelease]; [self.gameCenterManager setDelegate:self]; [self.gameCenterManager authenticateLocalUser]; } else { // The current device does not support Game Center. } } - (IBAction) showLeaderboard { GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != NULL) { leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self; [self presentViewController:leaderboardController animated:YES completion:nil]; } } - (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController { [self dismissViewControllerAnimated:YES completion:nil]; [viewController release]; } - (IBAction) showAchievements { GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init]; if (achievements != NULL) { achievements.achievementDelegate = self; [self presentViewController:achievements animated:YES completion:nil]; } } - (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController; { [self dismissViewControllerAnimated:YES completion:nil]; [viewController release]; } //GameCenter View Did Unload - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; self.gameCenterManager = nil; self.currentLeaderBoard = nil; self.currentScoreLabel = nil; } - (void)dealloc { [gameCenterManager release]; [currentLeaderBoard release]; [currentScoreLabel release]; [super dealloc]; } //End Game Center ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Don't forget to #import the following: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #import "AppSpecificValues.h" #import "GameCenterManager.h" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Jake
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/05/13 03:19 PM (12 years ago)
Thanks Jake! One less thing to worry about :) Cheers! -- Smug
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
06/06/13 10:59 AM (12 years ago)
I keep getting an error - unexpected @ in program on the last line here: //Start Game Center //GameCenter View Did Load -(void)viewDidLoad { [super viewDidLoad]; self.currentLeaderBoard = kLeaderboardID; self.currentScore = 0; Any ideas???
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
06/06/13 05:29 PM (12 years ago)
Try to remove the space between the ID and current score. Then put the self.currentScore on its own line. Jake
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
06/06/13 05:30 PM (12 years ago)
That got it, thank you
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.