简体   繁体   English

斯威夫特2:对于字典来说,表达式类型不明确,没有更多上下文

[英]Swift 2: Type of expression is ambiguous without more context, for a dictionary

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. 我已经浏览了所有其他相关问题,但都遇到了同样的错误,但未能找到解决方案。

How about 怎么样

let options : [NSObject : AnyObject] = [
    kCVPixelBufferCGImageCompatibilityKey: true,
    kCVPixelBufferCGBitmapContextCompatibilityKey: true]

[NSObject : AnyObject] is the equivalent to NSDictionary in Objective-C. [NSObject : AnyObject]等同于Objective-C中的NSDictionary The library you're using requires it to be of this type. 您使用的库要求该库属于这种类型。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 迅速地,“表达的类型是模棱两可的,没有更多的上下文”? - In swift,“Type of expression is ambiguous without more context”? Swift 3中的“表达类型不明确,没有更多上下文” - “Type of expression is ambiguous without more context” in Swift 3 Swift 2:表达式在没有更多上下文的情况下是模糊的 - Swift 2: Type of expression is ambiguous without more context 在Swift 3中没有更多上下文的表达式是模糊的 - Type of expression is ambiguous without more context in Swift 3 如何解决“在没有更多上下文的情况下含糊不清的表达类型”? 在迅速3.0 - how to resolve “Type of expression in ambiguous without more context”? in swift 3.0 Swift和HealthKit:在没有更多上下文的情况下,表达类型过于含糊 - Swift and HealthKit: type of expression too ambiguous without more context Swift 3:表达式类型[UIImage]在没有更多上下文的情况下是模棱两可的 - Swift 3: Expression type [UIImage] is ambiguous without more context 在 SWIFT 字符串插值中没有更多上下文的表达式类型不明确 - Type of expression is ambiguous without more context in SWIFT string interpolation Swift:“表达式类型在没有更多上下文的情况下不明确”与 URLSession - Swift: “Type of expression is ambiguous without more context” with URLSession Swift 2.0类型的表达式是模糊的,没有更多的上下文`.FlexibleHeight` - Swift 2.0 Type of expression is ambiguous without more context `.FlexibleHeight`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM