Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8198179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:53:48+00:00 2026-06-07T05:53:48+00:00

I have built objectives for my game and everything works just fine accept the

  • 0

I have built objectives for my game and everything works just fine accept the part of making the objectives not be called any more after any of them is completed.

I know there is a Property of the GKAchievement Class "completed" which is a boolean that returns yes when the Achievement is 100 percent done.

here is the method that called when a Achievement is 100 percent done it passes id which is the Achievement identifier and report the acheeee :

- (void)AchivmentDidAchive:(id)Achivment{
NSString *identifier = Achivment;
NSLog(@"%@",identifier);
self.achivment = [[GKAchievement alloc]initWithIdentifier:identifier];
self.achivment.showsCompletionBanner = YES;


if (!self.achivment.completed) {
    self.achivment.percentComplete = 100;
    NSLog(@"Reproting!");
    [self.achivment reportAchievementWithCompletionHandler: ^(NSError *error)
     {

     }];
}
else {
    NSLog(@"Achivment Completed!");
}   }

what I am trying to do here is to set the percent completed to 100 and report it so in the next time ie want get called again.

but it always works… any better idea for how to handle this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:53:50+00:00Added an answer on June 7, 2026 at 5:53 am

    in interface add variable & property:

    NSMutableDictionary *earnedAchievementCache;
    
    @property (nonatomic, retain)NSMutableDictionary *earnedAchievementCache;
    

    in .m:

    @synthesize earnedAchievementCache;
    
    - (void) submitAchievement: (NSString*) identifier percentComplete: (double) percentComplete
    {
    
    
    
    
    if(self.earnedAchievementCache == NULL)
    {
    
        [GKAchievement loadAchievementsWithCompletionHandler: ^(NSArray *scores, NSError *error)
         {
             if(error == NULL)
             {
    
                 NSMutableDictionary* tempCache= [NSMutableDictionary dictionaryWithCapacity: [scores count]];
                 for (GKAchievement* score in scores)
                 {
                     [tempCache setObject: score forKey: score.identifier];
                 }
                 self.earnedAchievementCache= tempCache;
                 [self submitAchievement: identifier percentComplete: percentComplete];
             }
    
    
         }];
    }
    else
    {
    
        GKAchievement* achievement= [self.earnedAchievementCache objectForKey: identifier];
        if(achievement != NULL)
        {
            if((achievement.percentComplete >= 100.0) || (achievement.percentComplete >= percentComplete))
            {
    
    
                achievement= NULL;
    
    
    
            }
            achievement.percentComplete= percentComplete;
        }
        else
        {
            achievement= [[[GKAchievement alloc] initWithIdentifier: identifier] autorelease];
            achievement.percentComplete= percentComplete;
    
            [self.earnedAchievementCache setObject: achievement forKey: achievement.identifier];
        }
        if(achievement!= NULL)
        {
            //Submit the Achievement...
    
    
            if (achievement.percentComplete>=100) {
               //show banner
                achievement.showsCompletionBanner = YES; //only in IOS 5+
            }
    
    
    
    [achievement reportAchievementWithCompletionHandler: ^(NSError *error)
             {
        if (error!=NULL){
                NSLog(@"Error!!");
        } else NSLog(@"all is well");
    
             }];
        }
    }
    
    
    }
    

    in dealloc :

    [self.earnedAchievementCache release];
    

    i’m using the cache to not submit scores already submitted / completed

    PS: the code is perfect just copy and paste it into your class and it will work

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a game in HTML5 and a web form posts data to
I have a game built on xcode using objective c. this game needs to
I have built Web sites with Python/Django and desktop applications with Objective-C/Cocoa so programming
I have built a site which requires user to login. Now I have decided
I have built so far an application that allows the user to drag and
I have built up an array of objects, created from a class, I wrote
I have built a local DVD Database using Codeigniter, With film names etc in.
I have built a Custom MaskedTextBox , changing the values of BeepOnError and AsciiOnly
I have built a mock object using EasyMock, and I'm trying to have the
I have built the UI for my Google Chrome Extension, but I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.