Optional Punctuation in Swift

All of the punctuation in Swift looked pretty weird to me until recently, but now that I get it, I’ve really learned to appreciate how great the syntax actually is. The way I think of it is this: if you’re using ?, you’re asking a question, and when you use ! you’re asserting that you already have the answer. Of course, for the second case, you need do need to be sure or your app will blow up.

So, for example:

Asking a Question

if let foo = dictionary["foo"] as? String { ... }

Is the value for the key “foo” a string? If so, assign it to the constant foo.

delegate?.objectDidSomething(self)

Do I have a delegate, and can it respond to objectDidSomething:?

Making an Assertion

managedObjectContext!.save(&error)

I know that managedObjectContext is not nil.

let foo = bar as! String

I know bar is a string, so nothing will go wrong casting it.

A Few Apple Watch Thoughts

  • Scratches show up on stainless steel easier than I expected. Thankfully it’s pretty easy to polish them out.
  • WatchKit apps have a lot better performance than I expected. Based on Twitter, I thought they’d be pretty much unusable.
  • Parts of the UI are a bit laggy, but I suspect that’ll be fixed in a software update.
  • The screen switching on automatically really only works when you’re standing with your arms at your side.
  • If I don’t wear the band fairly tightly, I miss taps.
  • I love not having everyone around me know when I get a notification.
  • Not having to fish my phone out of my pocket to find out why it’s buzzing is just as great as I hoped it would be.
  • I would really like a way to know who in my address book has an Apple Watch.

Real-World Testing with XCTest

Kind of old now, but I really like this post from the August issue of objc.io. The two things that stood out for me was that it used XCTest instead of a third party testing framework, and that it gives real examples of how to approach which tests to write. I’ve been totally totally on board with the idea of unit testing for a long time, but my biggest hurdle has always been knowing what to test. Thinking of what tests to write in terms of Given-When-Then pattern they go over has given me some new ideas.

Trying Swift Again

On my most recent project, I decided to try going Swift from the start. I did the same thing when I started working on a rewrite of the Lovely app around the end of last summer, but found the tools too immature then. This time I’ve spent about a week with it, and everything seems is working out fine (so far). I’ve tried to keep up reading about the language itself, so the syntax hasn’t held me back much. One difference between now and the last time I really dove into Swift is that either something in my brain has clicked regarding optionals, or the language changed a bit over the past six months to make optionals align with my brain more. I still can’t what the debugger commands are.

The other day on Twitter, I was part of a discussion comparing Swift to Objective-C. My feeling is that Swift isn’t better, but some parts of it are delightful to me, and I like it. For example, method overloading in Swift is pretty great, and I’m looking forward to doing interesting things with enums. Better though? In some ways, but not in others. Colin Cornaby pointed out that the ease of dropping down to C in Objective-C comes up a lot, and that C++ compatibility is pretty much a requirement for a lot of apps. I think he’s right.

The way I look at it is this: Objective-C didn’t have to be “broken” for Swift to be a great language. I don’t expect Objective-C to go anywhere in the near future, and that’s a good thing.

All the Zelda

Over the last few months I’ve become a tiny bit obsessed with Zelda games. I’d never really played one before last summer, and now I want to play them all, except maybe “The Adventure of Link” because I hear it’s terrible. 

Given that the hardware I have is a Wii U and a 3DS, there might be a few that I won’t be able to play, but I think I’ve collected all that I can. Maybe someone can let me know if I’m missing any though. 

Here’s what I’ve acquired so far – new, used, or Virtual Console – broken up by platform it ass originally released for:

NES

  • The Legend of Zelda (1986)

SNES

  • A Link to the Past (1991)

Gameboy

  • Link’s Awakening (1993)

Gameboy Color

  • Oracle of Ages (2001)
  • Oracle of Seasons (2001)

Gameboy Advanced

  • The Minish Cap (2004)

Wii

  • Twilight Princess (2006)
  • Skyward Sword (2011)

DS

  • Phantom Hourglass (2007)
  • Spirit Tracks (2009)

3DS

  • Ocarina of Time 3D (2011)
  • A Link Between Worlds (2013)
  • Majora’s Mask 3D (2015)

Wii U

  • The Wind Waker HD (2013)

My plan is to play them all in the order they were originally released in (not the date a remake was released), excluding the ones I’ve already beat. Now that I look at it though I’m realizing this is going to take forever. 

Idea for a Web App

All of my experience writing web apps have been to learn or test an idea, or something that I decided wasn’t such a great idea after all. For a long time I’ve wanted to come up with something useful enough to want to publish, but simple enough that I thought I could get it done in a reasonable timeframe as my first project. I think I’ve thought of something.

Neither Xbox Live, Nintendo Miiverse, or PlayStation Network gives you a way to find your Twitter/Facebook friends. What I’m thinking of doing is making a site (probably using Django) which lets you login with Twitter and/or Facebook, enter what someone would need to find you on any of those gaming networks, and then use that information to find your friends who’ve done the same on the site.

I’m imagining that as far as web apps go, this is a pretty simple one. In my mind it’s just social login, a form to enter your Xbox/Miiverse/PSN usernames, some API calls to get your friend lists, and some database queries to match it up to users of the site. Am I missing anything here?

My Everything Through the Xbox One Setup

I haven’t posted in a while due to a bunch of reasons, and I’d like to get into a rhythm again. I thought I’d start by sharing the kind of unique way I have my media stuff running through and Xbox One.

I’ve played a bunch of games on the Xbox since I got it in November — and a bunch of them have been great. But the Kinect and HDMI in are the unique part I wanted to mention. My set up is that I have a Kinivio HDMI switcher with a TiVo, Apple TV, and Wii U going into it, and the switchers output plugged into the Xbox. The Xbox can control be setup to control TV functions, and with the Kinect it can do those with voice commands (“volume up/down”, “mute”, “pause”, etc). Since I have everything running through my Xbox, I can keep using those commands with any of my other devices.

Having a bunch of things running through this specific HDMI switcher works especially well because it automatically switcher to any input that start getting a new signal, so I rarely have to manually switch inputs.

The only downside is that I have to have my Xbox One on to use anything else, but in practice that hasn’t been annoying at all.

Updating an iOS 6 App

Been working on a new version of an app of mine called Closeby that I haven’t touched since iOS 6.

A few thoughts about the process:

  • My design taste has come a long way in the last two years. Some features in I remember spending time on that now I can’t imagine why I’d want them. Others I didn’t do then seem obviously necessary and I have no idea why I didn’t.
  • I really like iOS 7+ style design.
  • I’m a lot better at programming than I was two years ago. It’s not awful, but there’s code in here I’d never have written today, and it’s nice to see than I haven’t stagnated.
  • Cocoapods can be a pain in the ass, but it’s still the best bad choice.

Maybe I’ll post some before and after screenshots when I get a chance to work on it more.

Brent Is Going to Omni

Brent Simmons is not only a friend, but one of my favorite Cocoa developers. His blog is the most indispensable about writing software I read. Omni is one of my favorite Cocoa development companies. Can’t wait to see what they do together.

360|iDev min

I’m super excited to be opening up 360|iDev min October 6th in South Carolina! I’ll be giving a talk about the design patterns, processes and tools we use to make our iOS app at Lovely. I’ve also seen a lot of the other speakers before at 360iDev proper, and they’re all wonderful.