Swift version of sample code from http://developer.apple.com/library/etc/redirect/xcode/ios/602958/samplecode/TheElements/Introduction/Intro.html