For the online mode for my game, I am using the context property of GKScore, and as all devices which support Game Center can update to iOS 5 (which is when the context property was added), I am requiring that the context property is available to play online. However, I am having issues implementing this runtime-check. I was assuming that I could use [GKScore instancesRespondToSelector:@selector(setContext:)] to check its existence, but this returns false on the iOS 5 and 5.1 simulators, as well as for @selector(context). Why on earth is this happening, and what is the cleanest and correct way to perform this check, please?
For the online mode for my game, I am using the context property of
Share
I can’t fully explain this, but an instantiated object of class
GKScorewill return YES torepondsToSelector(context), even while the class says it won’t. If no other solution works, construct aGKScoreobject just to query it.I wondered if
[[GKScore alloc] init]actually returns an object with type other thanGKScore. This can happen.But, it doesn’t, according to this output:
I wondered if the compiler directives in the
GKSCore.hheader file might affect this. It defines two properties that are only available in iOS 5.0 or greater:contextandshouldSetDefaultLeaderboard. Maybe those compiler directives mean that the class can’t guarantee it will support those two properties.Under this hypothesis
[GKScore instancesRepondToSelector:@selector(category)]should return YES, but[GKScore instancesRepondToSelector:@selector(shouldSetDefaultLeaderboard)]should return NO.But, the output is weirder than that: