Failing Actors Reading Series Brief thoughts on lessons we can learn from Erlang when designing reliable actors in Swift.
Statically-Typechecked Duck Types in Swift I present a hypothetical new Swift language feature which would allow something like duck typing in many use cases. This feature would be particularly useful in tests, where currently no good mocking/stubbing solution exists. The solution I propose achieves flexibility while maintaining the safety …
Modeling polymorphic relationships in Swift (spoiler: enums seem pretty cool) In traditional Objective-C code, we’d typically use protocols to express a polymorphic relationship. In Swift, we can take advantage of the language’s powerful enumerations to model these relationships, eliminate runtime type checks, and remove room for error in client code.
Working with custom UIView designated initializers I have a UIView subclass, with a custom designated initializer. How should I handle the requirement to override initWithCoder:?
Multiple Inheritance vs. Traits or Protocol Extensions A friend asked me at WWDC how Swift protocol extensions (or Scala traits, or Ruby mixins) are substantially better than multiple inheritance. Here are a few links and thoughts.
Casting in Swift 1.2: a brief summary Swift 1.2, in beta with Xcode 6.3, makes some changes to casting. Here’s how as, as?, and as! work: * as is for guaranteed conversions. That is, use as when the compiler can type-check that the conversion is valid; and Swift won’t compile a as cast it …
IBOutlet declarations in Swift Xcode’s default IBOutlet declarations are weak references to implicitly unwrapped optionals. This is wrong.
Let’s talk about Optionals There has been much complaining that Swift's Optional type forces you to think about whether something may be nil at every use, but aren’t we thinking about that already, just maybe implicitly? Swift’s optionals simply formally enforce the thinking we already must consider when writing (or …
Benefits of Cocoa: Still here in Swift Until now we all agreed these were benefits of Cocoa: * C compatibility * Dynamic dispatch * Nil safety * Duck typing Now they're all bad? — Nick Lockwood (@nicklockwood) August 6, 2014 Sigh. Okay, let’s take this one item at a time: C compatibility Still there. Nil safety Was never there …