Convert CFString to String for kUTTypeImage in Swift 2.0 and XCODE 7

I got a CFString conversion. Error message:

Cannot set type value '[CFString]' to type value '[String].

How to fix?

picker.sourceType = UIImagePickerControllerSourceType.Camera picker.allowsEditing = false picker.mediaTypes = [kUTTypeImage] //Error Message : Cannot assign a value of type '[CFString]' to a value of type '[String]' picker.delegate = self picker.modalPresentationStyle = .Popover presentViewController(picker, animated: true, completion: nil)// 
+6
source share
1 answer

From the header file:

 public var mediaTypes: [String] // default value is an array containing kUTTypeImage. 

So you can just delete this line.

But if you want to keep it, you just need to be explicit what you want to do:

 picker.mediaTypes = [kUTTypeImage as String] 
+10
source

All Articles