I just dipped on Swift, and then Swift 1.2 appeared (breaking the working code)!
I have a function based on sample code from NSHipster - CGImageSourceCreateThumbnailAtIndex .
My previous working code:
import ImageIO
func processImage(jpgImagePath: String, thumbSize: CGSize) {
if let path = NSBundle.mainBundle().pathForResource(jpgImagePath, ofType: "") {
if let imageURL = NSURL(fileURLWithPath: path) {
if let imageSource = CGImageSourceCreateWithURL(imageURL, nil) {
let maxSize = max(thumbSize.width, thumbSize.height) / 2.0
let options = [
kCGImageSourceThumbnailMaxPixelSize: maxSize,
kCGImageSourceCreateThumbnailFromImageIfAbsent: true
]
let scaledImage = UIImage(CGImage: CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options))
}
}
}
}
Starting with Swift 1.2, the compiler provides two dictionary related errors options:
- The type of expression is ambiguous without additional context.
- '_' does not convert to 'BooleanLiteralConvertible' (in reference to true)
I have tried different ways to specifically declare types in the dictionary options (eg [String : Any], [CFString : Any], [Any : Any]). Although this may solve one error, they introduce other errors.
- ?
, - , Swift 1.2 , .