Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey, nil]; to Swift

Getting an error here. Racking my brain. Tried all sorts of combinations.

Cannot find an initializer for type 'NSDictionary' that accepts an argument list of type '(object:(Int), forKey: CFString!)'

// configure the pixel format -  Obj-C
// videoOutput.videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey, nil];

// Swift       
videoOutput.videoSettings = NSDictionary(object: Int(kCVPixelFormatType_32BGRA), forKey:kCVPixelBufferPixelFormatTypeKey)
like image 857
Edward Avatar asked Dec 14 '22 15:12

Edward


1 Answers

update: Xcode 7.0 • Swift 2.0

videoOutput.videoSettings = NSDictionary(object: Int(kCVPixelFormatType_32BGRA), forKey: kCVPixelBufferPixelFormatTypeKey as String) as [NSObject : AnyObject]

or just

videoOutput.videoSettings = [kCVPixelBufferPixelFormatTypeKey : Int(kCVPixelFormatType_32BGRA)]
like image 89
Leo Dabus Avatar answered Jan 18 '23 23:01

Leo Dabus