In my app I need to pick a file from iCloud and put it in an array. But I have no idea how to grab the file picked. Please see my code below and help to finish. Thank you for your time!
For iCloud, I picked key-value storage and iCould Documents
For iCloud, I picked key-value storage and iCould Documents
Code:
import UIKit
import MobileCoreServices
extensionViewController: UIDocumentMenuDelegate {
func documentMenu(documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) {
self.presentViewController(documentPicker, animated: true, completion: nil)
}
}
class ViewController: UIViewController {
var documents = [AnyObject]()
overridefunc viewDidLoad() {
super.viewDidLoad()
}
@IBActionfunc addDocuments(sender: AnyObject) {
let importMenu = UIDocumentMenuViewController(documentTypes: [kUTTypeTextasString, kUTTypePDFasString], inMode: .Import)
importMenu.delegate = self
self.presentViewController(importMenu, animated: true, completion: nil)
}
func documentPicker(controller: UIDocumentPickerViewController, didPickDocumentAtURL url: NSURL) {
let document = How to get the file here?
documents.append(document)
}
}
Last edited by a moderator: