in converting to swift 2 from 1.2 i'm getting an error, type of expression is ambiguous without more context.
var recordSettings = [
AVFormatIDKey: kAudioFormatLinearPCM,
AVSampleRateKey : 44100.0,
AVNumberOfChannelsKey: 1,
AVLinearPCMBitDepthKey : 32,
AVLinearPCMIsFloatKey : true
I have no idea what the problem is . I've tried casting to [String:AnyObject] but with no luck. any suggestions are appreciated.
答案 0 :(得分:2)
The type inferencer is having trouble realizing that kAudioFormatLinearPCM
is an alias for UInt32
and that that can be boxed in an NSNumber
.
So help it:
var recordSettings:[String:AnyObject] = [
AVFormatIDKey: NSNumber(unsignedInt: kAudioFormatLinearPCM),
AVSampleRateKey : 44100.0,
AVNumberOfChannelsKey: 1,
AVLinearPCMBitDepthKey : 32,
AVLinearPCMIsFloatKey : true]