3

我目前正在制作一个应用程序并且遇到了一些困难,这里是代码:

-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)ButtonIndex {
              if (ButtonIndex == 1) {

                   - (void) reportScore: (int64_t) score forCategory: (NSString*) category
                   {
                       GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:@"123"] autorelease];
                       scoreReporter.value = score;

                       [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
                           if (error != nil)
                           {
                               // handle the reporting error
                           }
                       }];
                       else if (ButtonIndex==2){
                           - (void) showLeaderboard:
                           {
                               GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
                               if (leaderboardController != nil)
                               {
                                   leaderboardController.leaderboardDelegate = self;
                                   [self presentModalViewController: leaderboardController animated: YES];
                               }
                           }

                       }

                   }


                  -(void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController{

                      [self dismissModalViewControllerAnimated:YES];

                   }



                   }



              }

我的问题是在线:-(void)reportScore:(int64_t)............它说“无效的参数类型无效到一元表达式”

请帮忙,谢谢。

4

1 回答 1

4

您在另一个方法中声明方法,这是您无法做到的。分别声明所有方法,并在适当的地方调用它们。

- (void) reportScore: (int64_t) score forCategory: (NSString*) category
 {
                   GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:@"123"] autorelease];
                   scoreReporter.value = score;

                   [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
                       if (error != nil)
                       {
                           // handle the reporting error
                       }
                   }];
}
- (void) showLeaderboard:
   {
                       GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
                       if (leaderboardController != nil)
                       {
                           leaderboardController.leaderboardDelegate = self;
                           [self presentModalViewController: leaderboardController animated: YES];
                       }
   }
-(void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{

              [self dismissModalViewControllerAnimated:YES];

}
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)ButtonIndex {
          if (ButtonIndex == 1)
            {
                [self reportScore:score forCategory:cat];
             }
          else if (ButtonIndex==2)
            {
                 [self showLeaderboard];
            }

 }
于 2012-08-22T15:36:50.940 回答