有没有人找到
的替代品 [GKAchievement reportAchievementWithCompletionHandler]
?
通常,当事情被弃用时,文档表示替换。到目前为止,对于这个问题并非如此,我想把这个问题从我们看到的另一个问题的可能原因列表中删除。
答案 0 :(得分:12)
正在寻找相同的信息,并看到了你的帖子,这里是我没有找到任何东西后去了:
NSArray *achievements = [NSArray arrayWithObjects:achievement, nil];
[GKAchievement reportAchievements:achievements withCompletionHandler:^(NSError *error) {
if (error != nil) {
NSLog(@"Error in reporting achievements: %@", error);
}
}];
答案 1 :(得分:0)
这适用于iOS7,没有任何问题。
- (void)checkAchievements
{
if(myScore >= 25000){
GKAchievement *achievement= [[GKAchievement alloc] initWithIdentifier:@"Achiev1"];
achievement.percentComplete = 100.0;
achievement.showsCompletionBanner = YES;
[self Achievements:achievement];
}
}
-(void)Achievements:(GKAchievement*)achievement {
NSArray *achievements = [NSArray arrayWithObjects:achievement, nil];
[GKAchievement reportAchievements:achievements withCompletionHandler:^(NSError *error) {
if (error != nil) {
NSLog(@"Error in reporting achievements: %@", error);
}
}];
}
答案 2 :(得分:0)
这是Apple的完整代码(与Silly Goose的答案相同/相似)
- (void) completeMultipleAchievements
{
GKAchievement *achievement1 = [[GKAchievement alloc] initWithIdentifier: @"DefeatedFinalBoss"];
GKAchievement *achievement2 = [[GKAchievement alloc] initWithIdentifier: @"FinishedTheGame"];
GKAchievement *achievement3 = [[GKAchievement alloc] initWithIdentifier: @"PlayerIsAwesome"];
achievement1.percentComplete = 100.0;
achievement2.percentComplete = 100.0;
achievement3.percentComplete = 100.0;
NSArray *achievementsToComplete = [NSArray arrayWithObjects:achievement1,achievement2,achievement3, nil];
[GKAchievement reportAchievements: achievementsToComplete withCompletionHandler:^(NSError *error)
{
if (error != nil)
{
NSLog(@"Error in reporting achievements: %@", error);
}
}];
}