1

i am developing a sport application in IOS using Game Center integration. I have already configured all Game Center functions in my app, the only thing that is driving me crazy is the fact that i cannot increase the achievement percentage. I want to do something like this:

GKAchievement *ach1 = [[GKAchievement alloc] initWithIdentifier:
                         @"1"];
ach1.percentComplete=ach1.percentComplete+50;

Is there a way to increse the percentage like this? Because i have 2 achievements in Game Center that reward the player for everytime he plays the game. For instance:

  • Achievement one: Play 5 games
  • Achievement two: Play 10 games

So my main goal is to get the previous achievement percentage and increase it with a constant. The fact is ach1.percentComplete always return 0. Is there a way to make it return the previous percentage? Thanks for answering.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Victor Pinto
  • 177
  • 1
  • 9

2 Answers2

0

Not exactly what you have asked for, but I think you need to go about this a different way.

The number of games the user has played, should be part of some user data structure that is saved on the device.. and then update the percentage complete using that data.

But to expand a bit more on getting the current progress of an achievement, you should check to see if ach1 is null or not before accessing anything off of it. If ach1 is valid, then maybe there is a problem with the writing of current progress.

srzdev
  • 202
  • 1
  • 2
  • 10
  • I was thinking on an small database to store that data, but i thought that GKAchievement had a method to retrieve the achievement progress and increase it. – Victor Pinto Oct 25 '13 at 18:27
0

If you load all achievements and iterate them using GKAchievement loadAchievementsWithCompletionHandler percentComplete will contain the current value. Check the question's code here: GameKit achievement questions

Apple makes it wonky ...

Martin Braun
  • 10,906
  • 9
  • 64
  • 105