'What is the syntax for this closure for fetchDatabaseChangesResultBlock?
iOS Cloudkit FetchDatabaseChangesOperation() has a closure block defined as:
fetchDatabaseChangesResultBlock: ((_ operationResult:
Result<(serverChangeToken: CKServerChangeToken, moreComing: Bool), Error>) -> Void)?
My question is, what does an actual closure block look like?
For example, I tried this, which compiles:
let operation = CKFetchDatabaseChangesOperation(previousServerChangeToken: changeToken)
operation.fetchDatabaseChangesResultBlock = {
result in
}
In need to get the serverChangeToken, the moreComing value, and the Error. But I can't figure out what "result" is, or even if I have the right signature.
Any help would be appreciated! I can't figure this one out.
Followup: based on the answer, here is the concrete code that solved the problem.
operation.fetchDatabaseChangesResultBlock = {
result in
switch result {
case .success(let tuple):
let token = tuple.serverChangeToken
let moreComing = tuple.moreComing
// Do something
}
case .failure(let error):
// Handle error
break;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
