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

  • Home
  • SEARCH
  • 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 8273609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:31:53+00:00 2026-06-08T07:31:53+00:00

Following a book tutorial and seem to run into a snag with the isGameCenterAvailable

  • 0

Following a book tutorial and seem to run into a snag with the “isGameCenterAvailable” error.

Apparently it is undeclared. Everything else seems to work however so I just need to figure this part out.

Helloworldlayer .m init method

#import <GameKit/GameKit.h>

GameKitHelper* gkHelper = [GameKitHelper sharedGameKitHelper]; gkHelper.delegate = self;
[gkHelper authenticateLocalPlayer];        


Class gameKitLocalPlayerClass = NSClassFromString(@"GKLocalPlayer"); bool isLocalPlayerAvailable = (gameKitLocalPlayerClass != nil);
// Test if device is running iOS 4.1 or higher
NSString* reqSysVer = @"4.1";
NSString* currSysVer = [[UIDevice currentDevice] systemVersion]; bool isOSVer41 = ([currSysVer compare:reqSysVer
                                                                                                   options:NSNumericSearch] != NSOrderedAscending);

isGameCenterAvailable = (isLocalPlayerAvailable && isOSVer41); 

-(void) onLocalPlayerAuthenticationChanged {
    [delegate onLocalPlayerAuthenticationChanged]; 
}






-(void) authenticateLocalPlayer {
    GKLocalPlayer* localPlayer = [GKLocalPlayer localPlayer]; 
    if (localPlayer.authenticated == NO) {

        [localPlayer authenticateWithCompletionHandler: ^(NSError* error) {
        [self setLastError:error]; }];
    } 
}

Gamekit.h

  #import "cocos2d.h"
 #import <GameKit/GameKit.h>
 @protocol GameKitHelperProtocol
 -(void) onLocalPlayerAuthenticationChanged; -(void) onFriendListReceived:   (NSArray*)friends; -(void) onPlayerInfoReceived:(NSArray*)players; @end
 @interface GameKitHelper : NSObject {
   id<GameKitHelperProtocol> delegate; bool isGameCenterAvailable; NSError* lastError;
}
 @property (nonatomic, retain) id<GameKitHelperProtocol> delegate;

 @property (nonatomic, readonly) bool isGameCenterAvailable; @property (nonatomic,    readonly) NSError* lastError;
+(GameKitHelper*) sharedGameKitHelper;
 // Player authentication, info
 -(void) authenticateLocalPlayer;
 -(void) getLocalPlayerFriends;
 -(void) getPlayerInfo:(NSArray*)players; 



 @end  

helloworld layer.h

 #import "GameKitHelper.h"


  @interface helloworldlayer : CCLayer <GameKitHelperProtocol>

{



 }

gamekithelper. h

 #import "cocos2d.h"
  #import <GameKit/GameKit.h>
  @protocol GameKitHelperProtocol
  -(void) onLocalPlayerAuthenticationChanged; -(void) onFriendListReceived:(NSArray*)friends; -   (void) onPlayerInfoReceived:(NSArray*)players; @end
   @interface GameKitHelper : NSObject {
id<GameKitHelperProtocol> delegate; bool isGameCenterAvailable; NSError* lastError;
}
@property (nonatomic, retain) id<GameKitHelperProtocol> delegate;

  @property (nonatomic, readonly) bool isGameCenterAvailable; @property (nonatomic,     readonly) NSError* lastError;
  +(GameKitHelper*) sharedGameKitHelper;
 // Player authentication, info
 -(void) authenticateLocalPlayer;
 -(void) getLocalPlayerFriends;
 -(void) getPlayerInfo:(NSArray*)players; 



   @end  
  • 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-08T07:31:54+00:00Added an answer on June 8, 2026 at 7:31 am

    The problem is you never actually declare isGameCenterAvailable. To fix this, do this:

    //HelloWorldLayer.h
    @property (nonatomic) BOOL isGameCenterAvailable;
    
    //HelloWorldLayer.m
    @synthesize isGameCenterAvailable = _isGameCenterAvailable;
    

    UPDATE:

    To fix the delegate error, try this:

    //HelloWorldLayer.h
    @property (nonatomic, retain) id<GameKitHelperProtocol> delegate;
    
    //HelloWorldLayer.m
    @synthesize delegate;
    

    Hope this helps!

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

Sidebar

Related Questions

I'm following a OpenCV book's tutorial and the following code doesn't work: #include <iostream>
I am following along with a tutorial book on AJAX and I seem to
screenshot I'm following a tutorial (book) about building rails apps but i ran into
I'm currently following a tutorial in a book, and it instructs to create a
I am following a tutorial in the book Machine Learning for Hackers by Drew
I'm new to cakephp and following this tutorial. http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html I have created the blog
I'm currently following the Shovell tutorial in the Simply Rails 2 book. On page
We started following the CakePHP Blog tutorial hosted on the website cakephp.org - http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html
I'm new to rails and working my way into the tutorial here: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book I've
I am following this tutorial book that involves signing up and user creation for

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.