Hello,
I noticed that DBRestClient is asynchronous, it means that When I download file from Dropbox, I cannot read it immediately.
I put in place a While (to wait upload completed) but I have not success, could you please help?
Thanks
Sébastien
My VIEW code:
class ViewController: UIViewController, DBRestClientDelegate {
private var FileLoaded = false
...
@IBAction func btDownload(sender: AnyObject) {
txtFileReader.text=""
txtLogs.insertText("Start DL file \n")
let tmpDirectory = NSTemporaryDirectory()
let myFilename = tmpDirectory.stringByAppendingPathComponent("Test.txt")
FileLoaded=false
dbRestClient?.loadFile("/MyFolder/Test.txt", intoPath: myFilename)
while FileLoaded {
txtFileReader.text = String(contentsOfFile: myFilename, encoding: NSUTF8StringEncoding, error: nil)
}
txtLogs.insertText(" \(myFilename) \n")
txtLogs.insertText("End DL file \n")
}
func restClient(client: DBRestClient!, loadedFile localPath: String, contentType contentType: String, metadata metadata: DBMetadata!){
println("File loaded into path: \(localPath)")
FileLoaded=true
}
func restClient(client: DBRestClient!, loadFileFailedWithError error: NSError!){
println("LoadFile failed with error: \(error)")
}