0

My IDE show warning "Obsolete: Deprecated in iOS 7.0" this methods:

  • (GKScore) ReportScore()
  • (GKAchievement) ReportAchievement()

This methods it works on iOS 7, but use not problem?
Exist other methods on iOS 7?

Thanks!

Android Developer
  • 987
  • 1
  • 8
  • 22

2 Answers2

0

I used this method to report score in game center and it works.

-(void)reportScore
{
    if(isIOS7)
    {
        // Create a GKScore object to assign the score and report it as a NSArray object.
        GKScore *score = [[GKScore alloc] initWithLeaderboardIdentifier:_leaderboardIdentifier];
        score.value = _score;

        [GKScore reportScores:@[score] withCompletionHandler:^(NSError *error) {
            if (error != nil) {
                NSLog(@"score reporting error : %@", [error localizedDescription]);
            }
            else
            {
                NSLog(@"score reported.");
            }
        }];
    }
    else
    {
        GKScore *scoreReporter = [[GKScore alloc] initWithCategory:_leaderboardIdentifier];
        scoreReporter.value = _score;
        scoreReporter.context = 0;

        [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
            // Do something interesting here.
            if (error != nil) {
                NSLog(@"score reporting error : %@", [error localizedDescription]);
            }
            else
            {
                NSLog(@"score reported.");
            }
        }];
    }

}
Max
  • 2,269
  • 4
  • 24
  • 49
0

Objective-C methods start with a lower-case method. They are not called with rounded brackets. So, I:

  1. opened the documentation for GKScore;
  2. looked for anything deprecated and found -reportScoreWithCompletionHandler:;
  3. saw that +reportScores: withCompletionHandler: isn't deprecated.

And saw pretty much the same thing with the singular instance method being deprecated in favour of the collection class method in GKAchievement.

So: just use the collection methods. Deprecated methods hang around being unsupported for a while and then disappear. You can find out what's currently supported, very very quickly, by reading the documentation.

Tommy
  • 99,986
  • 12
  • 185
  • 204