Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't fully explain this, but an <em>instantiated</em> object of class <code>GKScore</code> will return <strong>YES</strong> to <code>repondsToSelector(context)</code>, even while the class says it won't. If no other solution works, construct a <code>GKScore</code> object just to query it.</p> <hr> <p>I wondered if <code>[[GKScore alloc] init]</code> actually returns an object with type other than <code>GKScore</code>. This can happen.</p> <pre><code>GKScore *instantiatedScore = [[GKScore alloc] init]; // Add autorelease if using manual reference counting. NSString* className = NSStringFromClass([instantiatedScore class]); NSLog(@"instantiatedScore class name = %@", className); </code></pre> <p>But, it doesn't, according to this output:</p> <pre><code>instantiatedScore class name = GKScore </code></pre> <hr> <p>I wondered if the compiler directives in the <code>GKSCore.h</code> header file might affect this. It defines two properties that are only available in iOS 5.0 or greater: <code>context</code> and <code>shouldSetDefaultLeaderboard</code>. Maybe those compiler directives mean that the class can't guarantee it will support those two properties.</p> <p>Under this hypothesis <code>[GKScore instancesRepondToSelector:@selector(category)]</code> should return <strong>YES</strong>, but <code>[GKScore instancesRepondToSelector:@selector(shouldSetDefaultLeaderboard)]</code> should return <strong>NO</strong>.</p> <pre><code>GKScore *instantiatedScore = [[GKScore alloc] init]; // Add autorelease if using manual reference counting. NSLog(@"GKScore category = %d", [GKScore instancesRespondToSelector:@selector(category)]); NSLog(@"instantiatedScore category = %d", [instantiatedScore respondsToSelector:@selector(category)]); NSLog(@"GKScore context = %d", [GKScore instancesRespondToSelector:@selector(context)]); NSLog(@"instantiatedScore context = %d", [instantiatedScore respondsToSelector:@selector(context)]); NSLog(@"GKScore shouldSetDefaultLeaderboard = %d", [GKScore instancesRespondToSelector:@selector(shouldSetDefaultLeaderboard)]); NSLog(@"instantiatedScore shouldSetDefaultLeaderboard = %d", [instantiatedScore respondsToSelector:@selector(shouldSetDefaultLeaderboard)]); </code></pre> <p>But, the output is weirder than that:</p> <pre><code>GKScore category = 0 instantiatedScore category = 1 GKScore context = 0 instantiatedScore context = 1 GKScore shouldSetDefaultLeaderboard = 1 instantiatedScore shouldSetDefaultLeaderboard = 1 </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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