I just updated to Xcode 7 beta with Swift 2.0. And when I updated my project to Swift 2.0, I got this error: "Type 'OSType' does not conform to protocol 'AnyObject' in Swift 2.0". My project works perfectly in Swift 1.2. And here is the code got error:
videoDataOutput = AVCaptureVideoDataOutput()
// create a queue to run the capture on
var captureQueue=dispatch_queue_create("catpureQueue", nil);
videoDataOutput?.setSampleBufferDelegate(self, queue: captureQueue)
// configure the pixel format
**videoDataOutput?.videoSettings = [kCVPixelBufferPixelFormatTypeKey: kCVPixelFormatType_32BGRA]** // ERROR here!
if captureSession!.canAddOutput(videoDataOutput) {
captureSession!.addOutput(videoDataOutput)
}
I tried to convert kCVPixelFormatType_32BGRA to AnyObject but it didn't work. Anyone could help me? Sorry for my bad English! Thankyou!
This is the
kCVPixelFormatType_32BGRA
definition in Swift 1.2:This is its definition in Swift 2.0:
Actually the
OSType
is aUInt32
which can't implicit convert to aNSNumber
:So try this:
or