Natasha The Robot

Currently learning... Swift!                                                                     You can follow me on Twitter here.                                            Subscribe via RSS here.

Swift: Unit Testing Tips and Tricks

Here are some tips and tricks I learned from writing my unit tests in Swift last week...

Swift: Manipulating Constant Objects

When I think of Constants, I think of objects that cannot be changed at all. In Swift, that is true for basic types like Strings, Ints, Bools, etc, but can get tricky with Objects.

Swift Debugging Tips

One of the most important skills every programmer needs to have is debugging! Ever since I've been working with Swift, I've been definitely off in my coding because Swift is different to debug than my usual Objective-C debugging flow. However, here are a few tips I've picked up recently.

Swift: Why You Should Love Default Parameter Values

So one of my current favorite features of Swift is the ability to set default parameter values in functions. That's because default parameter values make it very painless to add additional parameters to an existing function...

Swift: Don’t Forget To Keep Your IBOutlets Private!

In Objective-C, I've always put my IBOutlets into the method (m) file, making them private by default. In Swift, I'll have to remember to make my IBOutlets private.

Swift: Unwrapping Multiple Optionals

Believe it or not, but I'm still getting used to optionals in Swift. Just when I thought I got the hang of it, I had a new use-case came up where it was hard to figure out how to proceed...

Swift Enums: Don’t Forget to Unwrap!

I was working with an enum this morning, when I got a misleading error...

Swift: Array Iteration with Index

When iterating over an array, it is very common to need the index of the objects in the array. Here is how you would do this in Swift...

Swift: Init with _

I remember when I first watched the Advanced Swift WWDC14 talk, my first thought after "Whoa! Whoa! What are they doing?!!! I'm not ready for this!" was "why would you even want to do any of this?!!!" The code seemed so unreadable.

Swift: How To Conform to the Sequence Protocol

I was testing out the SwiftyJSON library this weekend, and got the following error when I tried to iterate over my JSONValue object - an array of dictionaries. This was not possible until I implemented the Sequence protocol. Here is how I did it...