我有一系列顺序的云工具包调用,以分别基于先前的获取来获取记录。这些提取中的任何一个都可能失败,然后我必须跳到上一个控制器。由于存在很多提取失败的地方,因此我必须在许多位置将popViewController嵌入到以前的控制器中。我可以避免这种情况,并在可能的情况下仅调用一次popover吗?
func iCloudSaveMeterHubPrivateDbCz() {
self.clOps.iCloudFetchRecord(recordName: locId,databaseScope: CKDatabaseScope.private,customZone: true,completion: { (locationRecord,error) in
guard error == nil else {
self.navigationController!.popViewController(animated: true)
return
}
self.iCloudFetchMeter(withLocationCKRecord: locationRecord!) { records,error in
if (error != nil ) {
if let ckerror = error as? CKError {
self.aErrorHandler.handleCkError(ckerror: ckerror)
}
self.navigationController!.popViewController(animated: true)
}
if let _ = records?.first {
self.clOps.iCloudFetchRecord(recordName: contactId,completion: { (contactRecord,error) in
if let ckerror = error as? CKError {
self.aErrorHandler.handleCkError(ckerror: ckerror)
self.navigationController!.popViewController(animated: true)
}
DispatchQueue.main.async {
if let record = contactRecord {
record.setObject("true" as NSString,forKey:"assignedEEP")
}
}
}
self.navigationController!.popViewController(animated: true)
}
}
})
}