I am creating UIImagePickerController
to take a photo like this. However, at this statement,
cameraUI.mediaTypes = [kUTTypeImage]
it shows error like this:
fatal error: array element cannot be bridged to Objective-C
How shall I do? I am now using Xcode 6 beta version 4.
func presentCamera()
{
cameraUI = UIImagePickerController()
cameraUI.delegate = self
cameraUI.sourceType = UIImagePickerControllerSourceType.Camera
cameraUI.mediaTypes = [kUTTypeImage]
cameraUI.allowsEditing = false
self.presentViewController(cameraUI, animated: true, completion: nil)
}
Edited - I have got error like this.
You need to import MobileCoreServices
as kUTTypeImage
defined in MobileCoreServices
as let kUTTypeImage: CFString!
.
So add the framework MobileCoreServices
and write import MobileCoreServices
in your .swift
file.
Go to BuildPhase
-> Link Libraries
-> +
-> MobileCoreServices.framework
and add import MobileCoreServices
in your .swift
file.
Edit: Replace your line with as kUTTypeImage is optional so unwrap it
cameraUI.mediaTypes = [kUTTypeImage!]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With