By Casey Liss

In my new gig, my first assignment has been to work on a proof-of-concept app that demonstrates a new architecture we’re considering. (If you care, a combination of VIPER and RxSwift.)

This new app is written entirely in Swift. I’m new to Swift.

Taking inspiration from Brent Simmons’s Swift Diary, there are a few things about Swift that are deserving of praise and I plan to call out as I’m learning the language.

Today’s case study: Enumerations.


Enumerations are not a new construct; they’ve been in most languages I’ve worked with. Generally speaking, they look something like this, in most C-derived languages:

enum LibraryBookState {
    CheckedIn,
    CheckedOut
}

Think of it as saying “For a library book, it can either be CheckedIn or CheckedOut. Nothing else.”

As with life, things are rarely that simple.

In this contrived example, it’s useful to know that the library book is checked out to someone, but to whom? We’d need another variable to track the patron the book is checked out to. So, if we were designing a Book class in Swift, it may look like this:

class Book {
    var status: LibraryBookState
    var checkedOutTo: Patron?
    var title: String
    var author: String
}

That’s a little, well, weird, if you think about it. The patron the book is checked out to is really part of the state of the book. A part of the state that we’re capturing in the LibraryBookState enumeration.

Wouldn’t it be nice if we could keep track of who the book is checked out to within the LibraryBookState enumeration?


In Swift, we can. All thanks to associated values.

We can write a Swift version of our enumeration like so:

enum LibraryBookState {
    case CheckedIn
    case CheckedOut(patron: Patron)
}

Note the change in CheckedOut: now it looks like a function call. Though syntactically a little curious, CheckedOut is still just an enumeration value. However, it has a super power: it carries with it an associated value.

The only way to set a variable to the CheckedOut enumeration value is to also provide the associated Patron along with it.

let casey = Patron(name: "Casey Liss")
var state = .CheckedOut(patron: casey)

Similarly, when we are using a switch to evaluate the value of that enumeration, we can get the value back out:

switch state {
case .CheckedIn:
    // ...
case .CheckedOut(let p):
    // p is the associated Patron
}

Associated values are a perfect solution to a problem I didn’t know I had. To return to our Book class, we can now simplify it:

class Book {
    var status: LibraryBookState
    var title: String
    var author: String
}

We no longer need checkedOutTo since we’re capturing that within LibraryBookState. The revised class is much cleaner, and more directly represents the way we wish to model a book.


I’ve found associated values are used very frequently for the results of network requests. Many take a form like this:

enum FetchBookResult {
    case .Success(book: Book)
    case .Failure(error: ErrorType)
}

Using enumerations in this way makes it so much easier to return a value from a function, as you don’t have to do any awkward dancing with tuples or multiple callbacks or equivalent:

func fetchBook(id: Int) -> FetchBookResult {
    // ...
}

Enumerations in Swift have many other tricks as well:

  • Properties
  • Methods
  • Extensions
  • Protocols (think interfaces)

It’s stunning how powerful support for these paradigms makes enumerations.

I’m only three weeks in, but so far Swift is really impressing me. It’s bringing a joy to development that I haven’t felt in quite some time. I often feel like I’m fighting my own ignorance; I rarely feel as though I’m fighting the language.

There’s a lot in flux with Swift these days, which makes many people I deeply respect shy away from it. That may come to burn us, if we try to go all-in on Swift; especially once Swift 3 comes along. However, I’m very hopeful and excited for the future, as it’s clear Swift is a language that is somehow able to be both well-considered and improving rapidly.


 

If memory serves, I met Dave Wiskus at Çingleton in 2013. I had heard the name numerous times, as I was starting to really travel in the same circles. I knew him as a designer, and frequent speaker. We hung out a bit, and I like to think, clicked pretty quickly.

Through a couple WWDCs after, and at CocoaConf DC 2014, we got to know each other better and better. For a time, we worked together. I got to learn that, as with almost anyone you meet, there’s way more to Dave Wiskus than meets the eye. We became as close as new friends, separated by a few hundred miles, can reasonably be expected to be.

I knew that Dave had dabbled with music on and off throughout his life. I also knew his current career was as a designer, speaker, and producer. Over the last year or so, I noticed him getting more and more serious about his side project, Airplane Mode.

Late last year, Dave explained how serious he really was.

Today, Airplane Mode released their first studio EP, Amsterdam. A commendable achievement, but one that is not altogether remarkable.

Dave being Dave, and Airplane Mode being Airplane Mode, they did more.

In addition to being available on iTunes and Spotify, the album is also available in book form. (Apple links are affiliate links)

It’s a quick read—it took me well under half an hour—but it tells the story of how Amsterdam came to be. The story of what motivated this quartet of musicians to perform this quartet of songs that is now an EP.

The book goes further; Dave explains:

Over time, as we make music videos or play shows to support the album, we can update the iBook with new content. In the digital age there’s no reason why a record can’t be a living document.

Like so many truly clever ideas, this one seems so obvious, but only in retrospect. Though the only thing I can play with any efficacy is the stereo, I still wish I had thought of it.

What’s more, it’s only $4.

Go check it out. Between the album and the book it’s an hour of your life. I can think of many worse ways to spend $4 and 60 minutes.


self.employer = Employer()

Today, I start a new job.

I was at my prior employer for over three and a half years. My time there was, on the whole, wonderful. I’ve learned a ton—both what to do and what not to do—and am thankful for the experience. Should you need some .NET development work done, including but not limited to work with Sitecore, I’ll send you their way.

During my tenure, working as a .NET developer, I was always trying to find a way to, well, scare quote pivot scare endquote my career into iOS development. I was lucky enough to do one iOS project while at the old gig, but that was it. The rest of the time, I was working in C# as usual. I like C# quite a lot, but my heart isn’t really in it anymore.

Today, I join a local firm as an iOS developer. A dream of mine since I went to my first WWDC in 2011 is finally realized. Five years on, I’m finally walking the walk I’ve been talking about.

Just as exciting, the company I’m working for is not consulting. I’ve been working in consulting and/or government contracting (in many ways the same beast) since 2006. For a decade, I’ve been at the whims of various clients. Some of those clients—such as my last, actually—are wonderful. Some of these clients… are not.

The advantage of consulting is, if you don’t like what you’re working on (or who you’re working with), just wait a few months, and it’ll go away.

The disadvantage of consulting is, if you like what you’re working on (or who you’re working with), just wait a few months, and it’ll be taken from you.

I’m excited to see what the grass on the other side of the fence is like.

Me at WWDC, 2011
Me in front of Moscone West, WWDC, 2011

I’m absolutely petrified. I’m not a professional iOS developer… until today. Though I’ve been dabbling in it for years now, this is out of my comfort zone. I’ve spent the last few days looking at the Swift book, and I’ve been listening to Under the Radar, Mobile Couch, and Core Intuition, among others. I’m immersing myself as much as I can, but there’s no way to learn like trial by fire.

I’m so excited for this opportunity, made possible in no small part by some great friends. I’m glad to have some familiar faces to welcome me at this new gig. I’m nervous as hell that I won’t pick it up as quickly as I want to.

More than anything, I’m so stoked to be here. It’s been a long time coming.

As I write this, I have yet to speak about this job change on either of my podcasts. I know that Myke and I will be discussing this at length on the forthcoming episode of Analog(ue). When that episode is published, it will be available here. (Until then, around the 21st, that link will be broken.)

It’s time to throw caution to the wind. It’s time to be brave. It’s time to step away from the safety net.

Let’s do this.


 

On today’s episode of Clockwise, I joined Dan Moren, Aleen Simms, and Jason Snell to discuss four tech topics, all within 30 minutes.

This week’s episode includes streaming services we rely on, home automation we’re proud of, rumors of Apple moving toward exclusive video, and great customer service stories.

As I’ve said in the past, Clockwise is one of my favorite shows to guest on. It always keeps me on my toes, and I’m always stunned how much we can get through in so little time.


The Ultimate Rollercoaster

Tonight, after dinner, I was sitting near Declan trying to catch up with the Apple earnings call that was in progress. He was a few feet away, content and entertaining himself. A few minutes later, I hear him laughing hysterically. Erin is across the room, hiding, pretending she is going to sneak up on him.

I immediately join in the fun, pretending that I’ll protect Declan from Erin’s attacks. He clings to me, laughing and wailing in the happy way only an infant or toddler can.

Declan turns his head back, looking to see if Erin has moved closer while he was clinging to me. Sometimes she has, sometimes not. No matter what, once Declan locates her again, it’s back to the screams of both surprise and delight. He turns away from her, buries his head in my shoulder, clinging for dear life against the would-be attacker.

Erin is laughing. I’m giggling. Declan is nearly at the point of needing to take a break so that he can breathe he’s having so much fun.

Suddenly, like a freight train, I realize, this is that moment.

When we were having troubles conceiving, I always dreamed about what it would be like to play with my son or daughter. To giggle with them, to chase them, to be chased by them. To hear my wife and son chortling as they take part in this faux chase, to join them in their laughter, is without hyperbole, a dream come true.

I don’t close my eyes, as I don’t want Erin to catch me taking in this moment; I’m scared it will ruin it. I drink it in, as best I can, while still participating.

I’m such a lucky man.


Tonight, before our bedtime, Declan wakes up. He’s only slightly fussy at first, but over time ramps up quite a bit. I go in to try to comfort him, to no avail. After a little while, Erin goes in to do the same, and things are no better than when I left him. I wait a bit longer, and go in again.

Normally a very bad daytime sleeper, Declan is usually a champion nighttime sleeper. He goes 11 1/2 hours on most nights, and 12 hours isn’t entirely uncommon. When he does have a bad night, it hits us like a ton of bricks, since it’s so out of the ordinary.

Returning in to Declan this second time, I’m extremely frustrated. I’m trying to get a blog post posted before bed, and this is really cramping my style. I have no answers for him, and he has none for me. This is the pits.

I go in again, spend some time with him, and get him to the point that he’s at least considering sleep again. A small victory. As I sit here now, Declan is still fighting, the end of the battle nowhere in sight. This is shaping up to be a long night.


All of this happened within 3 hours.

Parenting is a rollercoaster. A beautiful, awkward, wonderful, disastrous rollercoaster.

One I hope never ends.

The 5K iMac

When I was in college, back in the early aughts, my computer was a tower that my father and I had built together. Having found my old website from that time, where I thought it necessary to share this information, I can tell you it was a whopping 1GHz and had 256 MB of RAM. I even had a 250 MB internal ZIP drive and an IBM flat-panel display. This was back when you didn’t see them detached from laptops. I was hot stuff. Well, I thought so anyway.

Before the end of college, I got a ThinkPad T30. I ran both machines in parallel. In the dark ages before Dropbox, this was a total pain. But I made it work, mostly using Windows Briefcases.


Fast forward to a few weeks ago, and I had been rocking a 15" MacBook Pro for work for three years. My own computer was a non-retina, high-res, anti-glare, late 2011 MacBook Pro. This computer hadn’t left my desk for any real stretch of time since I received my work MacBook Pro three years ago. Since my MacBook Pro didn’t have a SSD, I found it intolerable to use.

This year, I decided it was time for something new.

Thinking about my computing needs, I began to wonder: should I really get a laptop again? Or is it time for me to come crawling back to desktops?

I have a brand-new iPad Mini 4 which I love. I have this 2011 MacBook Pro I could always put a cheap SSD in. I have Erin’s MacBook Air I can use in a pinch, as long as I keep liquids away from it. What’s tying me to a laptop other than momentum?

Having heard my friends Marco, Dave, and Jason rave about their 5K iMacs, especially for the iOS developers, I thought it was time to give it a whirl.

I decided to do what I had previously thought unthinkable: I bought a 5K iMac. Well, I bought two. The first arrived effectively DOA (more on that on my podcast), and was returned. The second has been running flawlessly for a week now.

I ordered the mid-range 27" iMac, with upgraded processor (4.0 GHz), upgraded SSD (1 TB), and 32 GB of aftermarket RAM. I ordered mine with the new Magic Keyboard and Magic Mouse 2.

New Desk Setup

This machine is incredible.

It’s extremely fast, in every measurable way. The SSD is fast. The processor is fast. Everything just seems so fast. Even as compared to my Mid 2015 Retina MacBook Pro.

Most striking is the screen. That seems obvious at first—27 inches is quite a lot of inches. I had played with the iMac at the Apple Store a couple times, and it seemed neat. Once you start actually doing work on one of these machines—start doing the things you normally do—it is quickly obvious how amazing the screen real estate is. I regularly have 20"+ screens connected to my MacBook Pro, and even the combination of the onboard and externals screens seems so cramped now. I’ve been utterly ruined. In a week.

Another interesting artifact of this newfound real estate is that it’s changing the way I interact with OS X. On my laptops, I’m a very heavy Spaces user. I have my virtual desktops set up just right, so that I can keep things separated both mentally and, to some degree, physically as well. What with each of my virtual desktops on the iMac having around three times as many pixels as my MacBook Pro’s, I don’t need virtual desktops near as much.

Don’t look now, but I’m turning into John Siracusa.


The iMac’s accessories are also my first exposure to the new generation of Apple accessories. The Magic Mouse 2 seems about the same to my hand. I know there are differences, but I don’t notice them. The internals I do notice, as I am happy to leave batteries behind for good.

The Magic Keyboard is a marked difference from what I’m used to. I have one of the older, three-battery aluminum Bluetooth keyboards. I’ve always liked Apple keyboards, though curiously, no two ever seem to feel quite alike. Nonetheless, this new, lower travel Magic Keyboard is my favorite of the bunch.

I like it to type on, but I also quite like the lower profile. Since it doesn’t have to make room for two (or three) cylindrical AA batteries, it’s far flatter, which I find more comfortable, if a bit unusual.

I also quite like the newly decreased key travel. I don’t mind how shallow it is at all. Having tried the MacBook One in stores, I found that keyboard mostly agreeable, the spacebar and Return keys excepted. The Magic Keyboard reaches a perfect compromise between the keys I’m used to and the ones in the MacBook One.

There is a catch.

Weirdo arrow keys

The new arrow keys are driving me batty. Unbeknownst to me, my fingers have always found the arrow keys by looking for the dead space above the half-height left and right arrows. On the Magic Keyboard, the left and right keys are now full-height. My fingers find this terribly unbalanced, as the up and down arrows are still half-height. I’m sure I’ll get used to it over time; a week in, I’m not there yet.


A week in, I haven’t found any reason to regret getting a desktop. There have been times I’ve wanted to sit next to my wife and work on something—like this blog post—but just saving it for when I’m really concentrating seems like the better answer anyway. Then I can give Erin the attention she deserves, as well as what I’m doing on the iMac once I sit down in front of it.

Perhaps Jason put it best:

This is the promise of the 27-inch iMac with Retina 5K Display: It’s one of the fastest Macs ever attached to the best Mac display ever. Yes, it’s an iMac, meaning you can’t attach a newer, faster computer to this thing in two or three years. But I have a feeling that these iMacs will have the processor power, and the staying power, to make the aging process much less painful.


Snow Time-Lapse

Yesterday the Richmond area braced for 10+ inches of snow. We ended up getting maybe six inches, but that’s quite a lot for our neck of the woods. Further, as I write this, snow is still falling.

When the snow began, I set up my iPad Mini to take a time-lapse of it falling. All I did was perch it, open the stock camera app, set it to time-lapse, and hit start. Around 6 hours later I came back to it, and this is what it spit out.

Pretty cool stuff.


Tire Inflation 101

My father was a mechanic for Buick for a few years long before he even met my mother. Despite still wrenching on his cars to this day, I’ve inherited distressingly little of his mechanical prowess.

Basic car maintenance is all I can handle. Changing my oil, for example. I’m also capable of properly inflating my tires. I thought this was something everyone knew how to do, but in talking with friends and family lately, it’s becoming clear to me this common knowledge isn’t so common.

Tire Maximum Pressure

The above is the pressure rating on my tires. You’ll note it says the Max Pressure is 50 pounds per square inch. The key word here is maximum.

You should not be inflating your tires to this pressure.

The pressure shown on the tire is its maximum operating pressure. That’s a hint to you that you should never be filling your tire to that pressure. It’s the point of no return.

Instead, you should be looking for this:

Tire Pressure Label

In any car I’ve ever driven—American, Japanese, or German—this label is in the driver’s door jamb. On this label, you can see the recommended tire inflation, when the tires are cold, assuming normal load. In the case of my car:

Front tires: 36 PSI
Rear tires: 41 PSI

If I knew I was going to be loaded down really heavily, due to carrying lots of people, cargo, or a trailer, these pressures would change. In that case, I would consult my owner’s manual for the correct pressures.

You should always inflate your tires to the pressures in your driver’s door jamb or owner’s manual.

It’s also worth noting that as temperatures change, so will your tire pressures. Whenever you experience a large temperature swing, like the change between seasons, you should check your tire pressure. As the temperatures drop, your pressures will as well. As the temperatures rise, so will your pressures. Turns out PV=nRT does have a use, after all.

Remember that properly inflated tires are key for both safety and efficiency. Make sure you check your tire pressures periodically, and always inflate to what the car asks for, not the tire.


 

In a recent episode (Overcast Link) of Mac Power Users, Katie and David are joined by Todd Olthoff to discuss how to get started with Plex.

I’ve discussed Plex many times in the past. It’s a media manager that has some really awesome features:

  • Automatic metadata discovery such as cover art, cast information, etc.
  • Automatic on the fly transcoding for the device accessing the content
  • Access from anywhere if set up properly (i.e., I can view my Plex library from my iPhone, iPad, Fire TV Stick, or the web from anywhere I have an internet connection)
  • Ability to share libraries with friends and family, so you can easily browse and stream their media.

Nearly a year ago I wrote a primer on how to name files in a way that will best agree with Plex. That covers the most complex portion of setting up Plex, but only one part of it.

Episode 299 of Mac Power Users was a great walkthrough of why one would want to use Plex, how to get it installed, and the perks it provides. If you wanted a more in-depth look at why I love Plex so much, check it out. Katie, David, and Todd cover all the bases.


Some Random Thoughts on the Apple SIM

This Christmas, Erin went a bit crazy and bought me some goodies from Apple. The first I’d like to discuss is a new iPad Mini 4, with cellular.

An Aside: Why Cellular?

This iPad is my fourth. I had an original iPad, an iPad 3 (first with a Retina display), a “RetinaPad Mini” (first Mini with a Retina display), and now the Mini 4. Of those, the last two had cellular.

When I had my first two iPads, I frequently missed having an onboard cellular connection on them. I didn’t make the same mistake for the first Mini. However, between the first Mini and this one, I dropped my AT&T unlimited plan, and thus can now tether. I really considered going Wifi-only again. However, I didn’t want to regret it again.

In the first issue of the Six Colors Magazine, Jason Snell discusses making this call for his iPad Pro. Because he’s awesome, you can read his post here, but take it from a subscriber: you should really subscribe. I’m already in for a year and am glad I did after only one month. Anyway, to summarize, Jason’s justification was:

  • Having the iPad on a different carrier is often useful—sometimes you don’t have service on one carrier but may on the other.
  • Not nuking both the host and client batteries while tethering is useful

To prevent against future regret, I opted for a cellular model again.

The Apple SIM

Apple SIM

Since the iPad Air 2, Apple has included a special SIM card in cellular iPads. This SIM, called the Apple SIM, has a couple of neat tricks up its sleeve. First and foremost, it allows you to bounce between carriers without having to swap physical SIM cards. Furthermore, one of the carriers—GigSky— is specifically designed for international travel.

I knew the Apple SIM was a great idea, but I hadn’t yet read a really solid summary of what one needs to know about it. What follows is my crack at providing exactly that.


My first curiosity when it came to the options the Apple SIM would offer: what carriers would be available?

In the United States, here are my options:

AT&T, Sprint, T-Mobile, GigSky

Will the Apple SIM Get Locked?

Another thing that was unclear is whether or not the Apple SIM is locked once a carrier is selected. It didn’t seem too obvious to me until I checked out the options AT&T offered:

AT&T Will Lock Your SIM!

No other carriers showed such a warning.

Thus, it seems only AT&T locks your Apple SIM.

T-Mobile’s 200MB Plan

I’ve evangelized T-Mobile’s 200 MB for life data plan for a long time now. In short, they offer 200 MB of data per month, for free, for tablets, for the life of the device. I have a T-Mobile SIM I was using in my RetinaPad Mini, and I loved it.

Would that same SIM work in the new iPad?

I removed the Apple SIM, and inserted the T-Mobile SIM. It worked, no problem.


Next, I couldn’t help but wonder:

Does T-Mobile offer their 200 MB for life plan on the Apple SIM?

Yup.

Yup.

Switching Carriers

Once I activated my T-Mobile 200 MB for life plan, could I simultaneously activate another plan?

Changing Plans

Seems so. Once I tap the Add a New Plan button, I am presented with the same dialog shown in the first image above.

Wait a Second, What About Verizon?

Verizon has chosen not to jump on the Apple SIM bandwagon; to get your iPad on Verizon, you have to get a Verizon SIM card.

My RetinaPad Mini was a Verizon model, thus, it came with a Verizon SIM. I popped that SIM into my new Mini 4, and just like the T-Mobile SIM, it worked no problem.