ios - CloudKit saveRecord Complete -
i using code below update record. once record has been updated run refresh function. @ moment refresh function called before record has been updated refresh results same before record updated.
thanks
var tempdocumentsarray:nsarray! let recordid = ckrecordid(recordname: "layerabove") var predicate = nspredicate(format: "recordid = %@", recordid) let query = ckquery(recordtype: "layers", predicate: predicate) self.publicdb.performquery(query, inzonewithid: nil) { (results, error) -> void in tempdocumentsarray = results print("results are: \(tempdocumentsarray)") let record = tempdocumentsarray[0] as! ckrecord var layeraboveprevpos = record.objectforkey("layernumber") as! int layeraboveprevpos = layeraboveprevpos - 1 let nlnchanged = record.setobject(layeraboveprevpos, forkey: "layernumber") self.publicdb.saverecord(record, completionhandler: { (returnrecord, error) -> void in if let err = error { print("error: \(err.localizeddescription)") } else { dispatch_async(dispatch_get_main_queue()) { print("success") //todo:this called before save complete! self.resetandget() } } }) }
Comments
Post a Comment