I am receiving the following error in a callback to loadScoresWithCompletionHandler:
Error Domain=NSURLErrorDomain Code=-1005
"The operation couldn’t be completed. (NSURLErrorDomain error -1005.)"
Other calls to Game Center both before and afterwards succeed. (They operate on various threads). If have initialized the leaderboard request as follows:
GKLeaderboard *leaderboard = [[GKLeaderboard alloc] init];
leaderboard.identifier = leaderboardIdentifier; // valid identifier
leaderboard.playerScope = GKLeaderboardPlayerScopeFriendsOnly;
leaderboard.range = NSMakeRange(1, 100); // max. allowed range.
leaderboard.timeScope = GKLeaderboardTimeScopeAllTime;
[leaderboard loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) {
// ...
}];
What is going on here and how can I overcome this problem?
The calls to loadScoresWithCompletionHandler:
are made from an operation on an NSOperationQueue
whose task it is to issue requests for scores (I am interested in each localPlayerScore
) to several leaderboards and wait for all responses. The first response already carries the error.
UPDATE -1005 denotes kCFURLErrorNetworkConnectionLost
; the underlying cause is still unclear.
UPDATE If I send only a single request (instead of as so far typically 6 in parallel) I receive error NSURLErrorDomain
-1001, which denotes kCFURLErrorTimedOut
, or GKErrorDomain
3 ...
For some reason this alternative call does not lead to errors:
GKLeaderboard *leaderboard =
[[GKLeaderboard alloc] initWithPlayers:@[ GKLocalPlayer.localPlayer ]];
leaderboard.identifier = leaderboardIdentifier;
leaderboard.timeScope = GKLeaderboardTimeScopeAllTime;
[leaderboard loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) {
// ...
}];
Problem solved.