问题
Why is the compiler throwing an error for the following code that attempts to create a dictionary? How would you fix this code?
let options = [
kCVPixelBufferCGImageCompatibilityKey: true,
kCVPixelBufferCGBitmapContextCompatibilityKey: true]
I've looked through all of the other related questions with this same error and have not been able to find a solution.
回答1:
How about
let options : [NSObject : AnyObject] = [
kCVPixelBufferCGImageCompatibilityKey: true,
kCVPixelBufferCGBitmapContextCompatibilityKey: true]
[NSObject : AnyObject]
is the equivalent to NSDictionary
in Objective-C. The library you're using requires it to be of this type.
来源:https://stackoverflow.com/questions/33246582/swift-2-type-of-expression-is-ambiguous-without-more-context-for-a-dictionary