Optionals are another one of my favorite features of Swift. When I started learning Objective-C, I was so happy that sending messages to nil was basically a no-op that also returned nil, after coming from Java/C# where null reference exceptions required explicit null checking in most cases. Seeing nullability become a first-class concept in the type system where you can guarantee something will never be nil is the next evolutionary step from that, and I’m glad Swift chose to adopt this from other languages that have done so before.

Read more...

It’s been awhile since I wrote a blog post, and upon wanting to come back and do another I noticed that jekyll had been updated to 3.0 (jekyll is what generates this site, which I chose since it’s currently hosted on github pages which has native jekyll support). I typically am enthusiastic about upgrading to the most up to date versions of the software I use so I figured I’d give it a go. However I ran into a few roadblocks that I could not easily find answers to on duckduckgo/google so I figured I’d post them here in case anyone else hits them.

Read more...

Yesterday I decided to collect my weakify functions (that i’ve been tweaking since that post a bit for some new use cases I’ve discovered) into a framework that can be installed via cocoapods or carthage (or manually if that’s your thing). You can find the project (which has been given an extensive readme, Quick-based unit tests, and documentation comments) on GitHub here. If you’ve been using these functions at all, this should give you a better way to keep up to date with any changes you might be interested in.

Read more...

I haven’t played around with Swift 2 too much yet as I’ve been busy with other things in the past couple of months. However today I fired up Xcode 7 (beta 4) and tried converting the app I’m working on at work to Swift 2. It’s a hybrid app with much more Obj-C code than swift code presently, so there wasn’t too much for the converter to do, only a few syntactical changes in 8-10 files or so.

Read more...

My first major blog post here was on crafting the weakify function and how you could use it to weakly bind a method reference to an instance of the class the method is defined in, so that you could use the resulting function without worrying about potential memory retain cycles. I’ve used it numerous times in my projects, but in some cases it can get a bit unwieldy, such that an explicit closure would seem to be the shorter option.

Read more...

I recently ran into a curious problem on one of my side projects that I didn’t understand at first. I was using a swift protocol to provide a uniform interface for various possible kinds of collection view cells that all show a common source of data in different ways, and have a single delegate that they communicate through to respond to user input. A distilled version of what I was doing looked something like this:

Read more...

One of my favorite features of Swift is the fact that functions are first class values: they can be assigned to variables, passed around as arguments to other functions, and manipulated and decorated in numerous ways. You can even do this with methods on classes, structs and enums, since every type of function is represented in the same way in Swift.

Read more...

Welcome to my site. In the coming weeks I plan to post about various programming topics related to things I’m working on and learning. I’ll likely focus a lot on Swift and Apple’s development platforms since that’s the area I’m very interested in currently. I may also get personal and talk on other topics tangentially related (or even unrelated) to programming but those will probably be few and far between. I hope you’ll enjoy what you read!

Read more...