23
23
15
15

Swift has rich value types, which is a new experience for many software developers. This has opened the door for the functionalists to ride in.

What I call “functionalism” is really the philosophy of functional programming, which is in fact a very old idea. The idea is that a lot of bugs in programming today are due to having the wrong state. For example, the Heartbleed bug happened because someone re-used the same array for a different purpose. So the solution, clearly, is to get rid of mutable arrays, and mutable variables, and the assignment operator, and you can’t have the heartbleed bug now. (Why they did not also get rid of the programmer is an exercise left to the reader.)

Read More »

15
13
10
29

Let me introduce: SwiftyAs. It’s a tiny little library to provide sort of the same functionality as as? from Swift in Objective-C. Let me explain…

In Swift, you can use the as? operator to safely cast a variable to another type (albeit Optional). If the actual type at runtime doesn’t match, Swift turns it into a nil, and otherwise you just get the variable as an optional.

Read More »

23
21

Without 100% support for a mocking framework like OCMock, I found myself needing to get creative when building mock objects and method stubs in Swift unit tests. The great thing about testing is that you’re… well… testing things out to see if they’ll work, and I found a solution that I’m pretty happy with for now. I’m open to better ways, so leave a comment if you’ve had good results using a different design!

Read More »