Empty or optional arrays

Comment

Empty or optional arrays

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?

Comment

Using computed properties to provide display values for stored properties

Comment

Using computed properties to provide display values for stored properties

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.

Comment

Changing layout constraints at runtime

Comment

Changing layout constraints at runtime

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?

Comment

Substrings take 2

Comment

Substrings take 2

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.

Comment

Substrings

Comment

Substrings

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.

Comment

Apple's official Swift tweets

Comment

Apple's official Swift tweets

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. 🙂

Comment

NSUserDefaults

Comment

NSUserDefaults

A great, in depth post on dealing with NSUserDefaults in Swift. This allows for relatively easy persistence of the state of your app over restarts.

Comment