Statistically speaking it’s more likely for you to be mauled by a bear than for you to properly secure WordPress.
— Sad Server (@sadserver) February 24, 2015
Today I converted a small Swift 1.1 project to Swift 1.2. I did this with the very recently released 6.3β2 of Xcode. The convert function did a fair job. But I had to do some work by hand. Most of it was very straight forward. But there is one member function that gave me some trouble. It was a tiny change that was required. See if you can spot it.
func saveImage(path: String, type: String) { let image = createImage() let options: [String:AnyObject] = [kCGImagePropertyOrientation : 1, // top left kCGImagePropertyHasAlpha : true, kCGImageDestinationLossyCompressionQuality : 0.80] let url = NSURL.fileURLWithPath(path, isDirectory: false) var imageType = kUTTypePNG if type == "JPEG" { imageType = kUTTypeJPEG } let file = CGImageDestinationCreateWithURL(url, imageType, 1, nil) CGImageDestinationAddImage(file, image, options) CGImageDestinationFinalize(file) }
func saveImage(path: String, type: String) { let image = createImage() let options: [NSString:AnyObject] = [kCGImagePropertyOrientation : 1, // top left kCGImagePropertyHasAlpha : true, kCGImageDestinationLossyCompressionQuality : 0.80] let url = NSURL.fileURLWithPath(path, isDirectory: false) var imageType = kUTTypePNG if type == "JPEG" { imageType = kUTTypeJPEG } let file = CGImageDestinationCreateWithURL(url, imageType, 1, nil) CGImageDestinationAddImage(file, image, options) CGImageDestinationFinalize(file) }
I do not at present (and may never will) have a proper user interface for this project. It’s part of my language learning process to leave out such things and concentrate on implementing the algorithm.
This does not prevent me from using the frameworks. As you can see by the code, I’m using the QuartzCore framework for producing an image from some source of data. That data is computed using both GCD and vDSP. The latter is in the Accelerate framework. The computation of the data keeps all the CPU cores quite busy. Proper use of GCD prevents the requirement for synchronization. I use different queues to do the work.
There is another computation I want to add to the code before I put it up on GitHub. When I’ve got that complete, I’ll post again on this topic. Meanwhile, as an enticement, I’ve got an image to share that is created by the code base I am working on.

@sadserver @vranac statistically speaking it’s more likely for you to like using WordPress than for you to like being mauled by a bear — skoop:// (@skoop) February 24, 2015