[ad_1]
I am misplaced with the extension of File in iOS. I can present the recordsdata, navigate and present the thumbnails! Nonetheless, once I click on a file it does`t load, solely present the textual content. Right here is a picture once I click on a picture:
Right here is my code that load the file when has clicked:
override func startProvidingItem(at url: URL, completionHandler: @escaping ((_ error: Error?) -> Void)) {
///TODO CHECK IF EXISTS THE FILE (WITH DATE OR ID)
//guard !fileManager.fileExists(atPath: url.path) else {
// completionHandler(nil)
// return
//}
guard
let identifier = persistentIdentifierForItem(at: url),
let file = FileProviderEnumerator.dictionary[identifier.rawValue]
else {
completionHandler(nil)
return
}
FilesManager.sharedInstance().downloadFile(withIdentifier: file.identifier) { progress in
} withCompletionHandler: { (urlFile, apiError) in
guard let urlFile = urlFile else {
completionHandler(FileProviderError.noContentFromServer)
return
}
do {
let information = attempt Information(contentsOf: urlFile, choices: .alwaysMapped)
let created = self.fileManager.createFile(atPath: urlFile.path, contents:information, attributes:nil)
if(created) {
completionHandler(nil)
} else {
completionHandler(FileProviderError.noContentFromServer)
}
} catch let error{
print(error)
completionHandler(error)
}
/*
do{
let url = urlFile
itemCompletion(information, nil)
} catch let error{
print(error)
itemCompletion(nil, error)
}*/
//
}
}
Is it essential to do one thing else? For instance the strategy providePlaceHolder or one thing like that?
Actually thanks upfront an any assist with it.
[ad_2]
