swift - Document saved on iCloud Drive seems not to be downloaded on iOS -
i'll let user save backup of data using icloud drive. works good. if switch icloud drive enabled device, can't read file.
i can see backup file within icloud drive app, it's not downloaded, (it shows "download icloud symbol).
is possible force download of files available within directory if user wants restore backup?
using swift 2 on ios 8/9.
i've solved myself. i'll check whether backup file available , if needs downloaded. if so, i'll start download , inform user check in few seconds. not best solution, works.
func checkanddownloadbackupfile() -> bool{ if(iclouddocumentsurl != nil){ let file = iclouddocumentsurl!.urlbyappendingpathcomponent("backup.file") let filemanager = nsfilemanager.defaultmanager(); if !filemanager.fileexistsatpath(file.path!){ if filemanager.isubiquitousitematurl(file) { let alertview:uialertview = uialertview() alertview.title = "warning" alertview.message = "icloud busy syncing backup files. please try again in few minutes." alertview.addbuttonwithtitle("ok") alertview.show() { try filemanager.startdownloadingubiquitousitematurl(file) } catch{ print("error while loading backup file \(error)") } } return false } else{ return true } } return true }
Comments
Post a Comment