Automate Your Builds and Testing with Bitrise

Using didSet on Swift properties to clean up viewDidLoad

September 12, 2020 · 1 min read

We have all seen those big view controllers and especially viewDidLoad functions with a whole bunch of set up code in them. Well, there is a very simple idea you can use to clean at least some of it up and make things more readable in the process.

On properties, we can use didSet as a place to put our setup code in. In this video, I’ll refactor a few simple set up lines of code back up into the IBOutlets and away from the view controller load function.




Subscribe to site
Peter Witham

Web and Mobile Software Maker, Photographer and Podcaster. I live and breath creativity.
I'd love for you to connect with me via Twitter or if you are a photo person like myself, Instagram.