iphone - Wait until GameCenter score download id complete -


i download score gamecenter, don't know how wait, when score downloaded. when run code, returns null. think, method have wait when [leaderboardrequest loadscoreswithcompletionhandler: ... have score downloaded.

- (nsstring*) getscore: (nsstring*) leaderboardid {     __block nsstring *score = nil;     gkleaderboard *leaderboardrequest = [[gkleaderboard alloc] init];     if (leaderboardrequest != nil)     {         leaderboardrequest.identifier = leaderboardid;         [leaderboardrequest loadscoreswithcompletionhandler: ^(nsarray *scores, nserror *error) {             if (error != nil)             {                 nslog(@"%@", [error localizeddescription]);             }             if (scores != nil)             {                 int64_t scoreint = leaderboardrequest.localplayerscore.value;                 score = [nsstring stringwithformat:@"%lld", scoreint];              }         }];     }     return score; } 

the code completion handler called when operation complete (on thread).

you have several options there, can store score somewhere , post notification notify main thread operation completed.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -