Created
October 13, 2010 15:54
-
-
Save typeoneerror/624315 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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