斯威夫特2:对于字典来说,没有更多上下文,表达类型是模棱两可的 [英] Swift 2: Type of expression is ambiguous without more context, for a dictionary
本文介绍了斯威夫特2:对于字典来说,没有更多上下文,表达类型是模棱两可的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么编译器会为以下试图创建字典的代码引发错误?您将如何解决此代码?
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.
推荐答案
如何
let options : [NSObject : AnyObject] = [
kCVPixelBufferCGImageCompatibilityKey: true,
kCVPixelBufferCGBitmapContextCompatibilityKey: true]
[NSObject : AnyObject]
等同于Objective-C中的NSDictionary
.您正在使用的库要求该库属于这种类型.
[NSObject : AnyObject]
is the equivalent to NSDictionary
in Objective-C. The library you're using requires it to be of this type.
这篇关于斯威夫特2:对于字典来说,没有更多上下文,表达类型是模棱两可的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文