@IBAction func iCloudPlayer(_ sender: Any) {
var documentPicker = UIDocumentPickerViewController(documentTypes: ["public.txt"], in: UIDocumentPickerMode.import)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = UIModalPresentationStyle.fullScreen
self.present(documentPicker, animated: true, completion: nil)
}
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL){
if(controller.documentPickerMode == UIDocumentPickerMode.import){
let content = openFile(path: url.path, UTF8: String.Encoding.utf8)
titlePlayerContent.text = content
}
}
func openFile(path:String, UTF8:String.Encoding = String.Encoding.utf8) -> String?{
var error: NSError?
return FileManager().fileExists(atPath: path) ? String(contentsOfFile: path, encoding: UTF8, error: &error)! : nil
}
//Arguments labels '(contentsOfFile;,encoding;, erro:)' do not match any available overloads, error on ? String(contentsOfFile: path, encoding: UTF8, error: &error)! : nilUIDocumentPickerViewController загрузить текстовый файл из ICloud
какие-либо предложения, ребята? как я могу загрузить из iCloud, уроки, не работающие над Swift 3!
Вы смотрели на документацию Swift 3 для 'Строка 'и его' init' методы? – rmaddy
И ваша проблема не имеет ничего общего с 'UIDocumentPickerViewController' или iCloud. – rmaddy