It’s pretty rare that I publish anything about my work, but given the difficulty I had in figuring out this particular problem with online research (in the end, I only found the answer by experimenting) I thought it would be useful to others if I published the solution.
I needed to be able to change the colour of my entire interface when the user tapped a button. My first design consisted of a series of labels that were easily referenced by outlets. Later I decided a Table View was a better fit – but how to retrospectively update the colours of the table cells?
I have a model class which keeps, amongst other things, the user’s current location.
While the location is used for internal calculations, there is also a screen where I display the current location to the user. Formatting the two values for display is easy enough, but non-trivial and worth encapsulating. I found the simplest way to encapsulate it was by creating a computed property on the model class itself.
In the app I am currently building, I decided the square button I have in one corner looks too small on an iPad screen, but it’s OK on an iPhone screen. The button is drawn by a PaintCode style kit so resizing it, in general, wasn’t going to be a problem. But, I wondered, how could I go about the resizing?
So, after I came up with this idea, found the domain available, created the web site and tweaked it to my liking – I discover there is what appears to be an official @swifttips Twitter account from Apple.
Hopefully they don’t get upset about this little site – or maybe they’ll buy the domain for millions. I can only hope. 🙂
Lynda.com is a paid access site but has incredibly great content and is excellent value. I’m a member and I viewed their Swift – Essential Training course which I not only got value from but utterly enjoyed. In fact, I’ve viewed it twice.
They have other specialised Swift courses, too.