Not running on AppKit (main) thread when displaying Game Center leaderboard in OS X

688 Views Asked by At

Whenever I try to view game centers leaderboard ion OS X with this code:

GKGameCenterViewController *gameCenterController 
                             = [[GKGameCenterViewController alloc]init];
gameCenterController.gameCenterDelegate = self;

if (gameCenterController !=nil) {
    GKDialogController *sdc =[GKDialogController sharedDialogController];
    gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
    sdc.parentWindow = [NSApp mainWindow];
    [sdc presentViewController:gameCenterController];

}

(This is nearly a exact copy of apples documentation)

I get a:

*** Assertion failure in void assertRunningOnAppKitThread()(), /SourceCache/ViewBridge/ViewBridge-99/ViewBridgeUtilities.m:535 An uncaught exception was raised not running on AppKit (main) thread

The method is invoked by a click on a menuitem. What I have tried was wrapping the method in a dispatch_sync(dispatch_get_main_queue() block with no success.

Edit: Added the stack trace: enter image description here - Seems that it starts from main thread (menu click) and Game Center itself starts a new queue.?

What did I miss? Any ideas?

0

There are 0 best solutions below