Natasha The Robot

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

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

iOS Designers: Say Goodbye to Pixel Perfect

The future of design is already here, and it is very dynamic, exciting, challenging, and far from pixel perfect. Here is what today's iOS designers have to consider in their design (I know it's a lot harder than the pixel perfect version!):

iOS 8: Self Sizing Table View Cells with Dynamic Type

When Dynamic Type came out in iOS7, I was hoping to get to use it. After all, who doesn't want to make their app more readable for users who need it? In iOS8, adding Dynamic Type is so easy, a cave man can do it! Here is all you have to do...

Swift: How To Be Lazy

As an Objective-C developer, I use lazy loading of my properties whenever possible. Lazy loading is initializing your properties only when they are called. This way, memory is not allocated for that property until absolutely necessary, and if the property is actually never used, the memory doesn't get allocated at all. In Swift, creating lazy properties is easier than ever!

Swift: Beware of Computed Properties

Yesterday, I accidentally stumbled into yet another cool Swift feature: Computed Properties. I saw it used by someone else in their code, and found the syntax confusing enough at the time to think it did something different than it does! Beware...

Swift: Demystifying Parameter Names In Functions

One of the frustrating things I've encountered with Swift is how to work with parameter names in functions. Sometimes the parameter name is required and sometimes it's not. As an Objective-C developer, I LOVE having parameter names very explicitly present - I like how readable it makes the code. So I decided to investigate a bit to make sure I got the rules down for when I write my own classes and methods. Here is what I found...

Swift: Using Complex Enums To Improve TableViews

One of the things that puzzled me about Swift when it came out was that you could put functions in an enum! That seemed like a pretty crazy pattern. However, as I've been working on a few simple Swift TableViews and CollectionViews this week, I fell in love with how simple the complex Swift enum can make things.