Ben Scheirman

These fickle bits...

Menu

Runtime Size Class Changes in iOS 8

It’s been interesting to watch as Apple transitions from hard-coded device sizes, where you only have two real devices to think about (iPhone and iPad), to a more flexible approach that deals with devices of any size.

The hinting of a new potential screen size was so thick you cut it with a knife during WWDC. The engineers were practically winking at the audience. When they first announced that you could resize the simulator to “any arbitrary size” there was quite a bit of laughter, because it’s obvious that a larger iPhone is coming.

Many of the new APIs that we see in iOS 8 boil down to one thing: Getting rid of UI_USER_INTERFACE_IDIOM. (side note: can you imagine being an engineer in the room when the requirement came in and trying to estimate the ramifications? What a huge change.)

This means that there needed to be a way for UIPopoverController and UISplitViewController to work on iPhone, and allow a single Storyboards to address multiple screen sizes.

But the new APIs don’t just support a single code base & interface layout to work on iPhone & iPad, they also allow the screen size to change at runtime.

While watching WWDC Session 228, “A Look Inside Presentation Controllers” there are a couple of demos that show off changing the simulator size class & dimensions while the app is running.

Why is this significant? This hints at a larger change in iOS 8 where you’ll be able to do this as a user, being able to display multiple apps on the screen at once.

Indeed there seems to be code in Springboard on iOS 8 that points to this feature.Steve Troughton-Smith noted this a couple weeks ago:

We are in an interesting time, watching the tea leaves to see where Apple is headed. As an engineer it’s very exciting to see how Apple changes their frameworks to support new directions on iOS.

Ruby Style Iteration in Swift

It’s no secret I’m a fan of Ruby. Idiomatic Ruby iteration looks like this:

1
2
3
5.times do |i|
  puts "Iteration ##{i+1}"
end

This outputs:

Iteration #1
Iteration #2
Iteration #3
Iteration #4
Iteration #5

You can also iterate over collections in this way:

1
2
3
["apples", "bananas", "cherries"].each do |item|
  puts "Eating #{item}"
end

Regex in Swift

I’ve been playing around with Swift and one thing that struck me as odd/disappointing is the lack of regular expression literals.

First off, the language is new and yes I’ve filed a radar (rdar://17257306 for Apple folks). Please dupe it if you care about this.

What I mean by regular expression literals is this (Ruby code):

1
2
3
if name =~ /ski$/
  puts "#{name} is probably polish"
end

Fixing GitHub SSL Issue on 10.9.2

By now you’ve most likely heard about the egregious SSL flaw that has existed in OSX and iOS for a while now.

Yesterday, Apple (finally) released 10.9.2 which addressed the flaw, as well as some other features. Upon upgrading, I was more than slightly frightened to see this error when trying to open github.com:

Using Rbenv in Cron Jobs

When using rbenv on your server, you need to make sure that any gem command run needs to be executed with rbenv initialized. When you install rbenv locally or on the server, you typically have something like this added to your .bashrc:

1
2
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
...

Synchronizing Dotfiles

I’d put this off for far too long, but I finally released my dotfiles on Github. Part of the reason it took me a while is I already had a syncing solution in Dropbox. I’m still using Dropbox to synchronize between my own machines, but I now have them published on Github as well. In addition, I wrote a handy script (with some inspiration from Steve Harman’s dotfile setup) that symlinks the files into the right spot on the target machine:

Creating a Fusion Drive

Fusion Drive

I have a Late 2009 Core i7 27” iMac that was starting to feel old. Many seemingly simple tasks would cause the OS to beachball, which generally made me not want to use the computer.

This slowness occurred despite the machine having a still respectable 2.8 GHz Core i7 processors. In fact, running some benchmarks with Geekbench led me to believe the problem didn’t lie with my CPU; it was my disk.

Unfortunately Geekbench doesn’t have any disk benchmarks, so I used the relatively old Xbench as a baseline. Compared with my Retina MacBook Pro with a 512 GB SSD, this drive was painfully slow.

I’d read about SSD upgrades in the 27” iMac but I was faced with the ultimate trade-off: The raw speed of the SSD with the utter capacity of a traditional hard drive.

75 Essential Tools for iOS Developers

If you were to go to a master woodworker’s shop, you’d invariably find a plethora of tools that he or she uses to accomplish various tasks.

In software it is the same. You can measure a software developer by how they use their tools. Experienced software developers master their tools. It is important to learn your current tools deeply, and be aware of alternatives to fill in gaps where your current ones fall short.

With that in mind, I present to you a gigantic list of tools. Some of these I use daily, others I see potential in. If you have more tools you’d like to see here, just make sure to add a comment.

Speaking at Cocoa Conf PDX

I have the pleasure of speaking at Cocoa Conf PDX on August 15-16th. Cocoa Conf is always a great event, and I especially love traveling to my home state of Oregon. This time around I’ll be giving two talks:

  • The iOS Developer’s Toolbelt
  • Jenkins – Your personal butler for iOS automation

I hope to see you there!