I want to add achievements to my app. I added a achievement in itunesconnect and found this method in the reference library:
-(void) reportAchievementIdentifier: (NSString*) identifier percentComplete: (float) percent {
GKAchievement *achievement = [[[GKAchievement alloc] initWithIdentifier: identifier] autorelease];
if (achievement)
{
achieveme开发者_如何学运维nt.percentComplete = percent;
[achievement reportAchievementWithCompletionHandler:^(NSError *error)
{
if (error != nil)
{
// Retain the achievement object and try again later (not shown).
}
}];
} }
so I added this to my app. now I want that the achievement is unlocked when an int has the value 5. how could a method look like that unlocks this achievement when the int is 5?
it would be:
if(myInt >= 5)
{
[self reportAchievementIdentifier:@"myAchievement1" percentComplete:100];
}
精彩评论