Skip to content

Instantly share code, notes, and snippets.

@jerryhjones
Created October 1, 2012 04:07
Show Gist options
  • Save jerryhjones/3809413 to your computer and use it in GitHub Desktop.
Save jerryhjones/3809413 to your computer and use it in GitHub Desktop.
- (void)authenticateLocalPlayer
{
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
[self callSelfOnMainThread:@selector(didAuthenticateLocalPlayer:) withArg:error error:nil];
}];
}
- (void)callSelf:(SEL)selector withArg:(id)arg error:(NSError*)err
{
assert([NSThread isMainThread]);
if([self respondsToSelector: selector])
{
if(arg != NULL)
{
[self performSelector: selector withObject: arg withObject: err];
}
else
{
[self performSelector: selector withObject: err];
}
}
else
{
NSLog(@"Missed Method");
}
}
- (void)callSelfOnMainThread:(SEL)selector withArg:(id)arg error:(NSError*)err
{
dispatch_async(dispatch_get_main_queue(), ^(void) {
[self callSelf:selector withArg:arg error:err];
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment