Skip to content

Instantly share code, notes, and snippets.

@typeoneerror
Created October 13, 2010 15:54
Show Gist options
  • Save typeoneerror/624315 to your computer and use it in GitHub Desktop.
Save typeoneerror/624315 to your computer and use it in GitHub Desktop.
- (void)loadAchievements
{
NSLog(@"loadAchievements");
[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {
if (error != nil)
{
}
if (achievements != nil)
{
NSLog(@"Achievements loaded for player: %@", achievements);
NSMutableDictionary *tempCache = [NSMutableDictionary dictionaryWithCapacity:[achievements count]];
for (GKAchievement *achievement in achievements)
{
[tempCache setObject:achievement forKey:achievement.identifier];
}
self.achievements = tempCache;
[self callDelegateOnMainThread:@selector(didLoadAchievements:withError:) withArg:self.achievements error:error];
}
}];
}
- (void)loadAchievementList
{
NSLog(@"loadAchievementList");
if (self.achievementDescriptions)
{
[self callDelegateOnMainThread:@selector(didLoadAchievementList:withError:) withArg:self.achievementDescriptions error:nil];
return;
}
[GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:^(NSArray *descriptions, NSError *error) {
if (error != nil)
{
NSLog(@"error in loadAchievementDescriptionsWithCompletionHandler %@", error);
[self callDelegateOnMainThread:@selector(didLoadAchievementList:withError:) withArg:NULL error:error];
}
if (descriptions != nil)
{
NSLog(@"Achievement descriptions loaded: %@", descriptions);
self.achievementDescriptions = descriptions;
[self callDelegateOnMainThread:@selector(didLoadAchievementList:withError:) withArg:self.achievementDescriptions error:error];
}
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment