Dictionary now gives error 'not convertible to BooleanLiteralConvertible' since updating to Swift 1.2

醉酒当歌 提交于 2019-12-04 09:09:52

From the Xcode 6.3 release notes:

The implicit conversions from bridged Objective-C classes (NSString/NSArray/NSDictionary) to their corresponding Swift value types (String/Array/Dictionary) have been removed, making the Swift type system simpler and more predictable.

The problem in your case are the CFStrings like kCGImageSourceThumbnailMaxPixelSize. These are not automatically converted to String anymore. Two possible solutions:

let options = [
    kCGImageSourceThumbnailMaxPixelSize as String : maxSize,
    kCGImageSourceCreateThumbnailFromImageIfAbsent as String : true
]

or

let options : [NSString : AnyObject ] = [
    kCGImageSourceThumbnailMaxPixelSize:  maxSize,
    kCGImageSourceCreateThumbnailFromImageIfAbsent: true
]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!