Selectors are a native type in Objective-C (SEL). Not so in Swift, where the type is currently represented by what amounts to a String (technically the type is Selector, but in actual use it is currently indistinguishable from a regular String). Objective-C benefits from this primarily in Xcode — the compiler is able to both provide autocomplete for most selectors…
The Elegant Solution So I went to straight to the expert – Core Contributor to CocoaPods @NeoNacho, who pointed me to the following elegant solution: # Podfile platform :ios, '9.0' use_frameworks! # My other pods def testing_pods pod 'Quick', '0.5.0' pod 'Nimble', '2.0.0-rc.1' end target 'MyTests' do testing_pods end target 'MyUITests' do testing_pods end
As I write this, I have just pressed the submit button on my first app written in Swift: Sun & Moon. I covered it briefly before, but in short, it’s an app for checking the rise and set times of the sun and moon either locally or at a city somewhere on the planet. It was a project both to…
Here’s the core of the suggestion: “It is not uncommon to have a need for a reference type without a need for inheritance. Superclasses should be intentionally designed to be subclasses and the author required to opt-in to subclassing and member overrides where that is required by the design.” That is, the suggestion is that subclassing classes and overriding methods…
As the App Store has matured and its revenue streams diminished, I have needed to pursue consulting jobs to bolster my income. Unlike working fully for myself, clients want (quite reasonably) an estimate of what a job is going to cost before signing off to begin the work. Unfortunately, in software development, accurate estimates are notoriously the hardest things to…
Floating point logic is a sneaky problem in many programming languages, and Swift is no different. These innocent lines are completely incorrect: let d1 = 0.1 let d2 = 0.2 let d3 = d1 + d2 if d3 == 0.3 { //Do something } The contents of the if statement will never execute. Floating point numbers on computers are notoriously…
Async sugar looks like this: Async.background { println("This is run on the background queue") }.main { println("This is run on the main queue, after the previous block") } Instead of the familiar syntax for GCD: dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), { println("This is run on the background queue") dispatch_async(dispatch_get_main_queue(), { println("This is run on the main queue, after the previous block") }) })
iOS 9 and tvOS both brought with them a new addition called App Transport Security. In short, it means that, in an effort to encourage wider use of https, vanilla http connections will be prevented from connecting unless an exception exists in the app’s Info.plist. Both Portfolio and Studio Pro provide a companion Mac-based loading app. It provides a RESTful…
The promise of Swift looks great. Faster performance1, better error handling, and better compile-time bug detection sound like very welcome additions to the iOS/OS X development ecosystem. The thing is, though, there are problems, problems that make it impractical to put time into mastering the language. Swift is being actively developed as a language, so much so that Apple is…