chuki
Apple Fan
Profile
Posts: 119
Reg: Feb 21, 2012
princeton
1,290
07/24/12 06:27 PM (13 years ago)

Gamecenter problems XCode

Hi, I used MGBlue's tutorial for Gamecenter in my version 1.5 app. I'm always getting the following errors in this section. I have three issues of expected identifier or "(" for several of my brackets. another pressing issue is that I'm getting "Initializer element is not a control time constant" for the [[GKLeaderboardViewController alloc] init]; part. Can you guys help me fix both errors? Those are the only two holding me back and I've looked everywhere...Thanks!!! //submit score -(void)submitScore{ if(totalPoints > 0) { [self.gameCenterManager reportScore: totalPoints forCategory: self.currentLeaderBoard]; } GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != NULL) { leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self; [self presentModalViewController: leaderboardController animated: YES]; } } //show scoreboard -(void)showScoreboard{ GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != NULL) { leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self; [self presentModalViewController: leaderboardController animated: YES];
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/24/12 06:35 PM (13 years ago)
These lines should not be on the same line: //submit score -(void)submitScore{ if(totalPoints > 0) Should be: //submit score -(void)submitScore{ if(totalPoints > 0) That may be one problem.
 
chuki
Apple Fan
Profile
Posts: 119
Reg: Feb 21, 2012
princeton
1,290
like
07/24/12 06:38 PM (13 years ago)
Thanks! That helped for three errors but I still have the "Initializer element is not a control time constant" for the [[GKLeaderboardViewController alloc] init]; part. How are you supposed to fix that? I could not find a solution so far.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/24/12 06:41 PM (13 years ago)
Did you fix both sections? You also are commenting out this line: //show scoreboard -(void)showScoreboard{ Should be: //show scoreboard -(void)showScoreboard{
 
chuki
Apple Fan
Profile
Posts: 119
Reg: Feb 21, 2012
princeton
1,290
like
07/24/12 06:43 PM (13 years ago)
Thanks! However, now I'm getting the error "! Expected Expression" for this part of the code above: leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self;
 
chuki
Apple Fan
Profile
Posts: 119
Reg: Feb 21, 2012
princeton
1,290
like
07/24/12 06:57 PM (13 years ago)
I'm getting an "Expected expression problem" for this section leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self;
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/24/12 06:59 PM (13 years ago)
Try changing it from this: leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self; to this: leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self;
 
chuki
Apple Fan
Profile
Posts: 119
Reg: Feb 21, 2012
princeton
1,290
like
07/24/12 07:01 PM (13 years ago)
I'm still getting "Expected expression problem" just for the first line though leaderboardController.category = self.currentLeaderBoard;
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/24/12 07:11 PM (13 years ago)
All I can suggest at this point is you go back over the tutorial step by step and make sure you didn't miss anything or copy something incorrectly. It works with 1.5 and with a slight modification it works with 2.0.
 

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.