CKQueryOperation中的RequestRateLimited

时间:2015-04-23 23:28:51

标签: ios cloudkit

如果RequestRateLimited返回RequestRateLimited错误,是否应将相同的queryOperation添加到publicDatabase,还是应该根据游标收到新的queryOperation?如果发生dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), { // ..other things let qo = CKQueryOperation(query: query) let qcb: (CKQueryCursor!, NSError!) -> () = {cursor, error in if error == nil { //.. some code } else { if error.code == CKErrorCode.RequestRateLimited.rawValue { let retryAfter = error.userInfo![CKErrorRetryAfterKey] as! NSNumber dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(retryAfter.doubleValue * Double(NSEC_PER_SEC))), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { publicDatabase.addOperation(qo) // <- HERE is it ok? I get an error }) } else { // .. some other code } } } qo.queryCompletionBlock = qcb publicDatabase.addOperation(qo) // .. other things .. }) 错误,客户端是否会收到游标?

@farktronix:

  • 您不应该收到新的查询光标
  • 您可以再次重试相同的操作

我实施得好,因为我收到错误(在模拟器中,在互联网条件差的情况下)

  

- [NSOperationQueue addOperation:]:操作已完成且无法入队

roo> web gwt setup
Command 'web gwt setup' not found (for assistance press CTRL+SPACE or type "hint" then hit ENTER)
Located add-on that may offer this command
1 found, sorted by rank; T = trusted developer; R = Roo 1.3 compatible
ID T R DESCRIPTION -------------------------------------------------------------
01 Y Y 1.2.5.RELEASE Support for UI scaffolding using Google Web Toolkit.
--------------------------------------------------------------------------------
[HINT] use 'addon info id --searchResultId ..' to see details about a search result
[HINT] use 'addon install id --searchResultId ..' to install a specific search result, or
[HINT] use 'addon install bundle --bundleSymbolicName TAB' to install a specific add-on version
roo> addon install id --searchResultId 01
roo> Target resource(s):
-------------------
   Spring Roo - Addon - Google Web Toolkit (1.2.5.RELEASE)

Deploying...
done.

roo> 
roo> web  gwt setup
Command 'web gwt setup' not found (for assistance press CTRL+SPACE or type "hint" then hit ENTER)

1 个答案:

答案 0 :(得分:1)

如果收到CKErrorRequestRateLimited错误,则您不应该收到新的查询光标。

如果收到速率限制错误,您可以在CKErrorRetryAfterKey键下的userInfo字典中指定的时间后再次重试相同的操作。