Mircea Ispas
Mircea Ispas

Reputation: 20780

Gamecenter crash when I check if player is logged in

I have a crash on this line with bad access.

if([GKLocalPlayer localPlayer].authenticated == YES) 

I saw this code on several tutorials and I think it should work. Do I need to enable something before calling it?

EDIT: The crash is upper, on this line - I just separated the calls

player = [GKLocalPlayer localPlayer];

Upvotes: 0

Views: 860

Answers (2)

Mircea Ispas
Mircea Ispas

Reputation: 20780

This line:

player = [GKLocalPlayer localPlayer];

crashed because there was no autorelease memory pool in place before the call. Weird crash...

Upvotes: 0

Suhail Patel
Suhail Patel

Reputation: 13694

The getter is called isAuthenticated not authenticated. Use the following:

if ([GKLocalPlayer localPlayer].isAuthenticated == YES) 

There are more details in Apple's Game Center User Guide

Upvotes: 2

Related Questions