I am following Apple documentation for UIDocumentMenuViewController and the following is my code. importMenu.delegate = self doesn't work and Xcode shows: Cannot assign value of type 'ViewController' to type 'UIDocumentMenuDelegate?' . Please help. Thanks!
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let importMenu = UIDocumentMenuViewController(documentTypes: ["public.text", "public.data"], inMode: .Import)
importMenu.delegate = self
self.presentViewController(importMenu, animated: true, completion: nil)
}
}
According to UIDocumentMenuDelegate Protocol Reference, your
ViewController
must conforms toUIDocumentMenuDelegate
and must implementsdocumentMenu:didPickDocumentPicker: