Reputation: 6133
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.
Upvotes: 6
Views: 1303
Reputation: 37189
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!]
Upvotes: 11