Mixins over Inheritance
When coming from an Object-Oriented Programming language like ObjC, inheritence is often used to share code between multiple classes. But that solution is not always the best, and have some issues.
In today’s article, we’ll see how Swift’s Protocol Extensions and their usage as “Mixins” can change the deal.
Let's talk about Monads
In the last article, we played a lot with
flatMap, methods on the
Array types. What you probably didn’t realise is that you were manipulating Monads without knowing. But what is a Monad?
Thinking in Swift, Part 4: map all the things!
In previous articles of this series, we learned about using
flatMap on arrays. Today we’ll discover
flatMap also exists on Optionals. And on plenty of other types.
Thinking in Swift, Part 3: Struct vs. Class
Continuing my “Thinking in Swift” article series, today we’ll do a simple change that will simplify our code again: using a
Thinking in Swift, Part 2: map those arrays
In part 1 of this article series, we saw how to avoid force-unwrapping optionals, save ponies 🐴 and avoid crashes by doing so. In this part 2, we’ll refine our code to make it Swift-er, introducing
Thinking in Swift, Part 1 — Addendum: Sacrificing ponies
After publishing part 1 of my article series “Thinking in Swift”, I had some great feedback and reactions on Twitter. Today I wanted to build on those comments and talk about when it could be ok to use
! and sacrifice a pony 🐴.
Thinking in Swift, Part 1: Saving ponies
I often see newcomers to Swift try to translate their ObjC code into Swift. But the hardest thing when starting to code in Swift is not the syntax, but changing your way of thinking, to use the new Swift concepts which were unknown to ObjC.
In this article series, we’ll take an example of ObjC code and walk thru converting it to Swift, introducing more and more concepts along the way.
Fun with Functions
Today’s article is about doing some fun with Swift functions, like functions returning functions, currying and operators on functions.
URLs and Pattern Matching
Today’s goal is to parse URLs like
http://mywebsite.org/customers/:cid/orders/:oid so that we can determine it’s a customer’s order request and extract the order #
oid and customer #
cid from it.
We’ll try and do that in an elegant way, using pattern matching and variable binding.
Enums as constants
Use enums as constants for your images, colors, storyboards, and more… and make your code beautiful (and short, and with autocompletion, and error-free)