Skip to content

Commit

Permalink
Merge pull request #7 from Julioacarrettoni/master
Browse files Browse the repository at this point in the history
Added 2 methods to query number of total and completed achievements.
  • Loading branch information
funkyvisions committed Apr 30, 2013
2 parents 0d50861 + 586d355 commit 835c421
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions DDGameKitHelper.h
Expand Up @@ -55,4 +55,8 @@

-(GKAchievementDescription*) getAchievementDescription:(NSString*)identifier;

- (int) numberOfTotalAchievements;

- (int) numberOfCompletedAchievements;

@end
25 changes: 25 additions & 0 deletions DDGameKitHelper.m
Expand Up @@ -630,4 +630,29 @@ -(void) achievementViewControllerDidFinish:(GKAchievementViewController*)viewCon
[self dismissModalViewController];
}

- (int) numberOfTotalAchievements
{
int count = 0;
if (isGameCenterAvailable)
{
count = [achievementDescriptions allValues].count;
}
return count;
}

- (int) numberOfCompletedAchievements
{
int count = 0;
if (isGameCenterAvailable)
{
NSArray* gcAchievementsArray = [achievements allValues];
for (GKAchievement* gcAchievement in gcAchievementsArray)
{
if (gcAchievement.completed)
count++;
}
}
return count;
}

@end

0 comments on commit 835c421

Please sign in to comment.