Note that there are some explanatory texts on larger screens.

plurals
  1. POGame center score is not posting
    primarykey
    data
    text
    <p>I'm trying to add the score at the end of the game to Game Center but it's adding nothing to the game center. I'm searching all day long for the 'mistake' i made but i do not see anything?</p> <p>Here is a little bit of the code i us.</p> <h2>.h</h2> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import &lt;Foundation/Foundation.h&gt; #import &lt;GameKit/GameKit.h&gt; @class GKLeaderboard, GKAchievement, GKPlayer; int counter; @protocol TopscoreDelegate &lt;NSObject&gt; @optional - (void) processGameCenterAuth: (NSError*) error; - (void) scoreReported: (NSError*) error; - (void) reloadScoresComplete: (GKLeaderboard*) leaderBoard error: (NSError*) error; @end @interface Topscore : UIViewController &lt;NSObject&gt; { AVAudioPlayer *audioPlayer; IBOutlet UILabel *count; Topscore* Topscore; } - (IBAction)tweetTapped:(id)sender; - (IBAction) subScore; - (IBAction) showLeader; - (void) reportScore; @property (nonatomic, assign) id &lt;TopscoreDelegate&gt; delegate; + (BOOL) isGameCenterAvailable; - (void) authenticateLocalUser; @property (nonatomic, retain) Topscore *Topscore; @property (nonatomic, retain) NSString* currentLeaderBoard; @property (nonatomic, retain) UILabel *count; @property(nonatomic, readonly, retain) NSDate *date; - (void) reportScore: (int64_t) score forCategory: (NSString*) category; - (void) reloadHighScoresForCategory: (NSString*) category; @end </code></pre> <p>And the .m file looks like; i have a button in the xib file wich is connected to the IBAction <code>Subscore</code>. i'm not receiving errors but only a few warnings.</p> <pre><code>PerformSelector may cause a leak because its selector is unknown </code></pre> <p>This warning on line; </p> <blockquote> <p>[delegate performSelector: selector withObject: arg withObject: err];</p> </blockquote> <h2>.m</h2> <pre><code>@interface Topscore () @property (strong, nonatomic) NSString *imageString; @property (strong, nonatomic) NSString *urlString; - (void)clearLabels; @end @implementation Topscore @synthesize count, date, urlString = _urlString, imageString = _imageString, delegate, Topscore, currentLeaderBoard; - (void) callDelegate: (SEL) selector withArg: (id) arg error: (NSError*) err { assert([NSThread isMainThread]); if([delegate respondsToSelector: selector]) { if(arg != NULL) { [delegate performSelector: selector withObject: arg withObject: err]; } else { [delegate performSelector: selector withObject: err]; } } else { NSLog(@"Missed Method"); } } - (void) callDelegateOnMainThread: (SEL) selector withArg: (id) arg error: (NSError*) err { dispatch_async(dispatch_get_main_queue(), ^(void) { [self callDelegate: selector withArg: arg error: err]; }); } //.. + (BOOL) isGameCenterAvailable { // check for presence of GKLocalPlayer API Class gcClass = (NSClassFromString(@"GKLocalPlayer")); // check if the device is running iOS 4.1 or later NSString *reqSysVer = @"4.1"; NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending); return (gcClass &amp;&amp; osVersionSupported); } - (void) authenticateLocalUser { if([GKLocalPlayer localPlayer].authenticated == NO) { [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) { [self callDelegateOnMainThread: @selector(processGameCenterAuth:) withArg: NULL error: error]; }]; } } - (void) reloadHighScoresForCategory: (NSString*) category { GKLeaderboard* leaderBoard= [[GKLeaderboard alloc] init]; leaderBoard.category= category; leaderBoard.timeScope= GKLeaderboardTimeScopeAllTime; leaderBoard.range= NSMakeRange(1, 1); [leaderBoard loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) { [self callDelegateOnMainThread: @selector(reloadScoresComplete:error:) withArg: leaderBoard error: error]; }]; } //.. - (void) showAlertWithTitle: (NSString*) title message: (NSString*) message { UIAlertView* alert= [[UIAlertView alloc] initWithTitle: title message: message delegate: NULL cancelButtonTitle: @"OK" otherButtonTitles: NULL]; [alert show]; } - (void) scoreReported: (NSError*) error; { if(error == NULL) { [self.Topscore reloadHighScoresForCategory: self.currentLeaderBoard]; [self showAlertWithTitle: @"High Score Reported!" message: [NSString stringWithFormat: @"", [error localizedDescription]]]; } else { [self showAlertWithTitle: @"Score Report Failed!" message: [NSString stringWithFormat: @"Reason: %@", [error localizedDescription]]]; } } - (IBAction) subScore { GKScore *scoreReporter = [[GKScore alloc] initWithCategory:@"01"]; scoreReporter.value = counter; [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) { if (error != nil) { NSLog(@"Failed: %i", counter); } else { NSLog(@"Succes: %i", counter); [self callDelegateOnMainThread: @selector(scoreReported:) withArg: NULL error: error]; } }]; } </code></pre> <p>Please if u need more code just ask me!</p> <p>PS: The leaderbord is showing up but the scores posting/adding not adding after clicking on the button (IBAction)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload