Snippet of the Week: Pinning Views
Sometimes you just need to create AutoLayout constraints in code. Maybe you can’t (or won’t) use Interface Builder. Or you still have to support iOS 8, which means
UIStackView is out (though you can use OAStackView if you want). But, handling the
NSLayoutConstraint API is pretty cumbersome, especially for seemingly ‘simple’ layouts.
Snippet of the Week: `NSLocalizedString(_:)`
It’s a good habit to start localizing all your user-facing strings from the get-go, even if you’re just tinkering around on a side project. But, while this is a good habit, it riddles your code with strings like these;
Snippet of the Week: `grouped(by:)`
Last holiday, I had the opportunity to start on a new side-project. One of the techniques I touched on, was grouping an array of model objects into sections. Instead of writing my umpteenth
for-loop for this, I opted to create a generic function for it.
Thinking up Singletons
While exploring a rescue project, I came across singletons… tons and tons of singletons. There was even a
Singletons.swift that just instantiated the lot of them at runtime. Because reasons…