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)............「単項式に対して無効な引数タイプvoid」と表示されます

助けてください、ありがとう。

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 に答える