Class: GKAchievement
Overview
Your game uses a GKAchievement object to communicate with Game Center about the local player’s progress towards completing an achievement.
Instance Attribute Summary (collapse)
-
- completed
readonly
A Boolean value that states whether the player has completed the achievement.
-
- identifier
A string used to uniquely identify the specific achievement the object refers to.
-
- lastReportedDate
readonly
The last time that progress on the achievement was successfully reported to Game Center.
-
- percentComplete
A percentage value that states how far the player has progressed on this achievement.
-
- showsCompletionBanner
A Boolean value that states whether a banner is displayed when the achievement is completed.
Class Method Summary (collapse)
-
+ loadAchievementsWithCompletionHandler:
Loads previously submitted achievement progress for the local player from Game Center.
-
+ reportAchievements:withCompletionHandler:
Reports progress on an array of achievements.
-
+ resetAchievementsWithCompletionHandler:
Resets all achievement progress for the local player.
Instance Method Summary (collapse)
-
- initWithIdentifier:
Initializes a new achievement object.
-
- issueChallengeToPlayers:message:
Issue an achievement challenge to a list of players.
-
- reportAchievementWithCompletionHandler:
Reports the player’s progress to Game Center.
-
- selectChallengeablePlayerIDs:withCompletionHandler:
Finds the subset of players that can earn an achievement.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Attribute Details
- (Boolean) completed (readonly)
A Boolean value that states whether the player has completed the achievement. (read-only) The value of this property is YES if the percentComplete property is equal to 100.0; otherwise, it is NO.
- (String) identifier
A string used to uniquely identify the specific achievement the object refers to. The identifier property must match the identifier string for an achievement you created for your game on iTunes Connect.
- (NSDate) lastReportedDate (readonly)
The last time that progress on the achievement was successfully reported to Game Center. (read-only) On a newly initialized achievement object, this property holds the current date.
- (Float) percentComplete
A percentage value that states how far the player has progressed on this achievement. The default value for a newly initialized achievement object is 0.0. The range of legal values is between 0.0 and 100.0, inclusive.
- (Boolean) showsCompletionBanner
A Boolean value that states whether a banner is displayed when the achievement is completed. When an achievement is completed and the value of this property is YES, a notification banner is displayed to the player to inform them of the completed achievement. If the value of this property is NO, there is no visual indication that the achievement is completed. Your game should set this property to NO only when it wants to provide its own visual indicator that the achievement was earned. The default value is NO.
Class Method Details
+ (Object) loadAchievementsWithCompletionHandler(completionHandler)
Loads previously submitted achievement progress for the local player from Game Center. When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. Keep in mind that the completion handler may be called on a thread other than the one originally used to invoke the method. This means that the code in your block needs to be thread-safe.
+ (Object) reportAchievements(achievements, withCompletionHandler:completionHandler)
Reports progress on an array of achievements. Use this class method whenever you need to submit multiple achievement updates at the same time. Calling this method reports each of the achievements, exactly as if you called the reportAchievementWithCompletionHandler: method on each achievement object in the array. However, the entire operation can be processed more efficiently using this method, and the completion handler is only called once.
+ (Object) resetAchievementsWithCompletionHandler(completionHandler)
Resets all achievement progress for the local player. Calling this class method deletes all progress towards achievements previously reported for the local player. Hidden achievements that were previously visible are now hidden again.When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. Keep in mind that the completion handler may be called on a thread other than the one originally used to invoke the method. This means that the code in your block needs to be thread-safe.
Instance Method Details
- (Object) initWithIdentifier(identifier)
Initializes a new achievement object. Your game initializes a new achievement object only when it has not previously reported progress for that achievement. If your game has previously reported progress on an achievement, you should first retrieve the current progress by calling the loadAchievementsWithCompletionHandler: class method.
- (Object) issueChallengeToPlayers(playerIDs, message:message)
Issue an achievement challenge to a list of players. This method should be used only to implement your own custom challenge user interface. You should only issue challenges when the local player directs you to do so.If the achievement is marked as hidden in iTunes Connect, or if the challenged player has already earned the achievement and it is not marked as replayable, then the challenge is not issued.
- (Object) reportAchievementWithCompletionHandler(completionHandler)
Reports the player’s progress to Game Center. When the player makes progress towards completing an achievement, your game communicates the player’s progress to Game Center by calling this method. An achievement object is implicitly tied to the local player that was authenticated when the object was created; your game should only report progress when the same local player is still authenticated on the device.Note: To avoid using network bandwidth unnecessarily, only report an achievement when the player has made more progress towards completing it.When the progress is successfully reported, the achievement is made visible if it was previously hidden. The percentComplete and lastReportedDate property values stored on Game Center are updated if the new percentComplete value is greater than the value previously stored on Game Center. if the value of the percentComplete property was equal to 100.0, then the achievement is marked as completed and a banner may be shown to the player.When this method is called, it creates a new background task to handle the request. The method then returns control to your game. The background task automatically handles network errors, resending the data until the task completes. When the task is complete, Game Kit calls your completion handler. Keep in mind that the completion handler may be called on a thread other than the one originally used to invoke the method. This means that the code in your block needs to be thread-safe.
- (Object) selectChallengeablePlayerIDs(playerIDs, withCompletionHandler:completionHandler)
Finds the subset of players that can earn an achievement. When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. Keep in mind that the completion handler may be called on a thread other than the one originally used to invoke the method. This means that the code in your block needs to be thread-safe.