Atelier Clockwork

Repatterning

Swift Is Going to Require a Lot of New Habits

So I sat down and wrote my first real UIKit app in Swift 2.0. It's based on a personality test, and I'm probably going to scrub the actual content of the test from the app before open-sourcing the code, but I learned a lot of details while doing it.

the most interesting one is how much trying to be a good Swift citizen is going to force good practices that reach beyond the syntax and programming methodology.

This is one of the first projects where I've sucked it up and wrote my views as real subclasses of UIView rather than just adding a pile of subviews to the main view in the view controller. Wanting to makes any values non-optional, and the requirement to set non-optional values before calling super.init() means I added all of my subviews to the a UIView subclass with all of the properties exposed. This means better Model-View-Controller separation everywhere in the app, which should be very useful in the future.

The next thing that feels like a huge shift is the improved enumerations and structs/raw values. Not having to think about the different rules for Integer/Float/CGSize/etc takes a small but repetitive bit of friction out of my work. And having enumerations with non-integer storage, functions, static values, makes working with enumerations more powerful, and has interesting implications for maintainability in projects.