@@ -13,7 +13,7 @@ class ViewController: UIViewController {
1313 let result = CGImageSourceCopyPropertiesAtIndex ( src, 0 , nil ) as NSDictionary
1414 println ( result)
1515 // just proving it really is a dictionary
16- print ( result [ " PixelWidth " ] !) ; print ( " by " ) ; println ( result [ " PixelHeight " ] !)
16+ print ( result [ kCGImagePropertyPixelWidth as String ] !) ; print ( " by " ) ; println ( result [ kCGImagePropertyPixelHeight as String ] !)
1717 }
1818
1919 @IBAction func doButton2 ( sender: AnyObject ! ) {
@@ -22,13 +22,13 @@ class ViewController: UIViewController {
2222 let scale = UIScreen . mainScreen ( ) . scale
2323 let w = self . iv. bounds. width * scale
2424 let d = [
25- kCGImageSourceShouldAllowFloat : true ,
26- kCGImageSourceCreateThumbnailWithTransform : true ,
27- kCGImageSourceCreateThumbnailFromImageAlways : true ,
28- kCGImageSourceThumbnailMaxPixelSize : w
25+ kCGImageSourceShouldAllowFloat as String : true ,
26+ kCGImageSourceCreateThumbnailWithTransform as String : true ,
27+ kCGImageSourceCreateThumbnailFromImageAlways as String : true ,
28+ kCGImageSourceThumbnailMaxPixelSize as String : w
2929 ]
3030 let imref = CGImageSourceCreateThumbnailAtIndex ( src, 0 , d)
31- let im = UIImage ( CGImage: imref, scale: scale, orientation: . Up)
31+ let im = UIImage ( CGImage: imref, scale: scale, orientation: . Up) !
3232 self . iv. image = im
3333 println ( im)
3434 println ( im. size)
@@ -38,8 +38,8 @@ class ViewController: UIViewController {
3838 let url = NSBundle . mainBundle ( ) . URLForResource ( " colson " , withExtension: " jpg " )
3939 let src = CGImageSourceCreateWithURL ( url, nil )
4040 let fm = NSFileManager ( )
41- let suppurl = fm. URLForDirectory ( . ApplicationSupportDirectory, inDomain: . UserDomainMask, appropriateForURL: nil , create: true , error: nil )
42- let tiff = suppurl! . URLByAppendingPathComponent ( " mytiff.tiff " )
41+ let suppurl = fm. URLForDirectory ( . ApplicationSupportDirectory, inDomain: . UserDomainMask, appropriateForURL: nil , create: true , error: nil ) !
42+ let tiff = suppurl. URLByAppendingPathComponent ( " mytiff.tiff " )
4343 let dest = CGImageDestinationCreateWithURL ( tiff, kUTTypeTIFF, 1 , nil )
4444 CGImageDestinationAddImageFromSource ( dest, src, 0 , nil )
4545 let ok = CGImageDestinationFinalize ( dest)
0 commit comments