While writing my new Stretch Timer app, I needed to set lower and upper limits for three key numbers. I had them hardcoded as numeric literals but when I wanted to change one of them, it occurred to me there must be a better way.
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?
After some time away from Xcode, I got back into it again tonight. Meanwhile, I’ve got Xcode 7 installed and am hitting some differences thanks to Swift 2.
I guessed I’d find a nifty article on just about any Swift topic I needed, which could be linked here. I was wrong. I came to the below conclusion because I couldn’t find any articles (easily) which answered the problem and so had to go digging deeper for myself.
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. 🙂