Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why UIDocumentMenuViewController does not accept kUTTypeText?

I saw in this tutorial and also in Apple docs, that this bunch of code should work.

let d = UIDocumentMenuViewController(documentTypes: [kUTTypeText as NSString], inMode: .Import)
o.delegate = self
self.presentViewController(d, animated: true, completion: nil)

But I get a compile time error

enter image description here

like image 246
János Avatar asked Nov 29 '14 22:11

János


1 Answers

kUTTypeText is defined in the MobileCoreServices framework, so you should add

import MobileCoreServices

Also, as Bartłomiej correctly noticed, the type identifier has to be converted from CFString to String in Swift 2/Xcode 7:

UIDocumentMenuViewController(documentTypes: [kUTTypeText as String], inMode: .Import)
like image 102
Martin R Avatar answered Nov 14 '22 20:11

Martin R