[英]NSURLErrorDomain code=-1005 from GKLeaderboard loadScoresWithCompletionHandler:
I am receiving the following error in a callback to loadScoresWithCompletionHandler:
我在
loadScoresWithCompletionHandler:
的回调中收到以下错误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. 之前和之后对Game Center的其他呼叫均成功。 (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. 调用
loadScoresWithCompletionHandler:
是从NSOperationQueue
上的一个操作进行的,其任务是向几个排行榜发出分数请求(我对每个localPlayerScore
感兴趣),并等待所有响应。 The first response already carries the error. 第一个响应已经包含错误。
UPDATE -1005 denotes kCFURLErrorNetworkConnectionLost
; UPDATE -1005表示
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 ... 更新如果我仅发送一个请求(而不是到目前为止通常并行发送的6个请求),
NSURLErrorDomain
收到错误NSURLErrorDomain
-1001,它表示kCFURLErrorTimedOut
或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. 问题解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.