How to cancel a cloudKit operation due to timeout in Swift? -


i looking how cancel cloudkit operation due given timeout setting? case use ckmodifyrecordsoperation upload changes icloud, if failed, save failed records local storage. something, operation take long time...

so, want set timeout 60 seconds on operation, if timeout, cancel operation. use sleep func, though not in main thread, makes every added operation run @ least 60s. know not right solution. code below:

let uploadoperation = ckmodifyrecordsoperation(recordstosave: recordstosave, recordidstodelete: recordidstodelete) uploadoperation.modifyrecordscompletionblock = { (savedrecords, deletedrecordids, error) in     if let error = error {         ...         cloudkitmanager.persistentfailedrecords(savefailed, deletefailed)     }  }  cloudkitmanager.privatedb.add(uploadoperation)      sleep(60) if uploadoperation.isexecuting {     uploadoperation.cancel() } 

i did search timeout on operation, answer focus on nsurlsession, no answer cloudkit operation. , tried own property "timeoutintervalforrequest", doesn't work.

any appreciated! thank you!


Comments

Popular posts from this blog

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -