July 19, 2016

The Coordinator Pattern

Soroush Khanlou had a very interesting blog post a while back. In it he elaborates on his “coordinator pattern”. Its a very neat pattern in which you make all of your view controllers “flow agnostic”. Ie. they know nothing about the view controller hierarchy, when to push another view controller on the navigation stack, when to present a modal etc. All of that responsibility is delegated to a coordinator object.

Read more...
June 27, 2016

UIStackView with UITextView: Need constraints for Y position or height

Just today I had to replace a UILabel with a UITextView. The label was inside of a UIStackView that had its position pinned to the bottom of another view, hence growing upwards. I’m doing all of this in Interface Builder btw. Just as I let go of the text view I’ve dragged in I see that ominous red circle with an arrow show up. Indicating that there’s some problem with my layout.

Read more...
May 31, 2016

Swift Equatable and Hashable

Swift provides a protocol that you can conform to to let the world know that your objects or structs can be compared and found equal or not: Equatable. There’s also a protocol that allows you to use your objects as keys in a dictionary: Hashable. In an app I’m working on I’m making some of the models (structs) conform to these procotols so that I can make diffing and such when refreshing the UI.

Read more...
May 30, 2016

Delegate calls wrapped in computed properties

In the app I’m currently working I have a view that asks its delegate for the locale to use when rendering it’s model object. The model has strings for all of the supported locales embeded in it and its just a matter of using the correct one when rendering. The view itself can go through a number of different transitions which is why I need to ask the delegate a few times in a few different places for what locale to use.

Read more...
May 20, 2016

Getting rid of typographic orphans with Swift

I composed this little Swift string extension to get rid of typographic orphans when rendering titles and such: // // String+Typography.swift // FilibabaKit // // Created by Simon Ljungberg on 09/05/16. // Copyright © 2016 Filibaba. All rights reserved. // import Foundation extension String { /** String Without Orphan - Returns: The string with the last space replaced with a non-breaking space to avoid orphans. */ var stringWithoutOrphan: String? { get { let space = NSCharacterSet(charactersInString: " ") if let lastSpace = self.

Read more...
May 19, 2016

UIStackView: Left align without stretching

UIStackView introduced in iOS 9 is awesome. However, as someone coming from the HTML/CSS programming world I sometimes find that it does not really match up with the mental model I have of how it should work. There’s not any straight forward way of putting a number of absolutely sized items in a stack view and aligning them to either side. You can make them stretch to fill, distribute equally over the entire width of the stack view and you can center them.

Read more...
October 9, 2015

Live Debugging Node.js in Vim: update

Just wanted to post a super quick update! Since posting my article a few months back there’s been some activity in the repository for the node-vim-debugger! Looks amazing! (If I was the kind of person to take credit for stuff I’d like to imagine that I sparked the burst of development creating an issue. Luckliy I’m very humble and would never do such a thing. ;))

September 14, 2015

My Résumé: or How I Accidentally Built a Static Site Generator

One thing that I did not really realize when I started freelancing was that potentially customers sometimes asks for a résumé. I hadn’t had a résumé in over six years. And I probably only wrote one or two before that. So last week when I was approached by a company, that I really wanted to work with, asked for my résumé I sat down to write one. I opened up a new Google Docs file and started writing.

Read more...
August 16, 2015

Reactive Cocoa

Here’s a nice article that explains Reactive Cocoa in a very succint way. I don’t think I’ll ever really get into this style of programming (mostly because I don’t feel super comfortable basing an app entirely on third party frameworks). But I find it really fascinating and cool!

August 16, 2015

Node's Require and Browserify: Take 2

A while back I wrote about taking advantage of Node’s require algorithm with Browserify. While I liked the concept of doing that I never really liked how it made things look file-wise. Well. Turns out you don’t need to wrap your little module in a directory or give it a package.json! Say you have a module called… let’s say do-some-math that exports some fancy math functions that are unique do your project.

Read more...