Fix UIViewController supportedInterfaceOrientations() to use UIInterfaceOrientationMask and OptionSetType in Swift 2

There are many changes coming in Swift 2 that further unify the Swift language and provide better support and method signatures.

A welcome change is the OptionSetType in Swift 2, this makes it easier to work with settings that relied on bit masks (a complex topic of binary logic) to use a Set and it's common operations.

The automatic conversion utility didn't help fix this change, so I had to fiddle a few times until I figured it out.

You'll see an error for your supportedInterfaceOrientations() method because the method signature has changed again. It now returns a UIInterfaceOrientationMask instead of an Int. 

Error: Method does not override any method from its superclass

While it breaks code now, this change makes Swift easier to use moving forward. Changes to how Objective-C code looks using new macros, generic types, and the OptionSetType will improve how you write code in Swift.

// Swift 1.2
override func supportedInterfaceOrientations() -> Int {
    let orientation = Int(UIInterfaceOrientationMask.Portrait.rawValue | UIInterfaceOrientationMask.PortraitUpsideDown.rawValue)
    return Int(UIInterfaceOrientationMask.All.rawValue)
}

Becomes a bit more verbose and uses the array notation to create a OptionSetType. It seems you need to set the type, otherwise the statement gets interpreted as an Array type, which isn't what you want.

// Swift 2
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    let orientation: UIInterfaceOrientationMask = [UIInterfaceOrientationMask.Portrait, UIInterfaceOrientationMask.PortraitUpsideDown]
    return orientation
}

This new change helps make Swift 2 code feel more at home, and a little less crazy than the hoops you had to jump through in Swift 1.2 and earlier.

Links

Posted on June 23, 2015 and filed under swift.

Thunderbay 4 SSD and HDD Thunderbolt 2 storage reviewed for online video courses

If you work with 20 or more videos a year on a Mac, you’ll be interested in this review. I have been creating hundreds of videos as I have been teaching on YouTube, Skillshare, Udemy, and now my own website iPhoneDev.tv.

My needs for video storage have changed over the past three years as I created more and more content. My courses started small with only a handful of videos, but as I taught more and more topics, my recorded video content increased. Over the past year I filmed 300+ videos and started to work on improving both my workflow and how I managed my multimedia data.

I wanted to figure out if SSD was a better fit for my needs than an HDD RAID array. I reached out to the CEO of OWC and I was able to borrow two Thunderbolt 2 drives that would allow me to test the performance characteristics and get a sense for a real world use case. OWC makes the Thunderbay 4 and Thunderbay 4 Mini in both HDD and SSD variations.

Background

I have explored various backup solutions and workflows using Time Machine, external drives, online backup solutions, and NAS (networked storage).

Two years ago my first RAID drive was a Western Digital Thunderbolt Duo (4TB). In the beginning it was great at RAID 0 (speed), but that offered no data protection. One day the RAID failed to load and all the data was lost. I switched over to a RAID 1 (mirroring data) and it’s been slow ever since – you can see in my tests below.

Now I really had two requirements, I needed at least 2 TB of storage and at least 2x faster performance than my current Thunderbolt drive. After two years that should be easy to beat.

Video Review

Thunderbay 4 and Thunderbay 4 Mini Review

Over the past month I have been using two versions of the THunderbay 4 drives. I wanted to know how an SSD variant would perform in comparison to the HDD Thunderbay. For my tests I compared the Thunderbay 4 Mini RAID with 4TB of SSD (Four 1TB SSD drives) and the Thunderbay 4 RAID with 12 TB (Four 3 TB drives).

Thunderbay 4 Mini RAID with 4TB SSD

There are four 1 TB hard drives in this configuration, which I setup with two partitions – RAID 0 for speed and RAID 5 for redundancy.

Thunderbay 4 RAID with 12TB HDD

There are four 3 TB hard drives in this configuration, which I setup with RAID 5.

I didn’t setup a RAID 0 scratch space since I wasn’t sure if I wanted to be copying files back and forth, or just work in the final location. I deal with a lot of files, so moving things around necessarily was lower on my priority.

SSD or HDD?

I had four questions I wanted to answer in my testing.

Did I need a RAID SSD external drive? 

I always like fast things, getting an SSD external was appealing, but the biggest drawback was the lack of space. SSD drives are still very expensive compared to traditional disk drives, and in a RAID 5 configuration the performance gains weren’t as significant as I thought they would have been.

Running a Mac Pro 2013, I’m spoiled with an extremely fast internal Flash drive. Internal storage works great when I have space, but it doesn’t provide any redundancy or protection.

Would my use case warrant the speed?

Part of my testing was a little subjective based on the perceived performance in Final Cut Pro. Opening projects on any of the Thunderbay drives was very fast (1-2 seconds) versus the WD Thunderbolt Duo (4-5 seconds). Everything from video thumbnail previews as I worked with video felt faster with the newer drives (including the Mac Pro's internal Flash storage).

When I compared the two Thunderbay 4 external drives it didn't feel like there was a major difference between RAID 5 SSD versus RAID 5 HDD. Scrubbing and importing felt just as fast with the 1080p videos I was using. The difference between the RAID 5 SSD and RAID 0 SSD was also hard to tell – both felt fast.

RAID SSD might make more sense for videographers who are working with large 4K projects, who would be working with huge video files. I found that the majority of my work with 1080p was good enough on any of the Thunderbay 4 external drives. 

In my tests the Thunderbay drives performed at a 5x difference from my original WD Thunderbolt Duo, which was a welcome change.

Do I need more space?

Another bigger question was if the 4 TB drive in RAID 5 would be big enough. I’m really looking for a place to backup my course content videos that would offer fast access. At the rate I was creating video files, it started to feel that a 4 TB drive in RAID 5 might feel a little small to quickly. In RAID 5 you’ll lose 25% of the space, so that meant there would only be ~3 TB on the SSD version (maximum) and ~9 TB on the HDD version.

If space is a concern, it seems like you’d want to go bigger. Thunderbay drives can be daisy chained together, but my current focus is on a single drive purchase. More drives would create more noise as well.

Is it quiet?

Any of these multi-drive external enclosures are going to create some kind of noise. I found the Thunderbay 4 Mini to be quieter, but not as quiet as my Mac Pro 2013 or my older WD My Book Thunderbolt Duo.

The Thunderbay 4 with HDD drives was a bit louder, and it’s fan also made more noise. I’m not sure I’d call it whisper quiet, but I guess that term should give you an idea that it’s on par with someone whispering. It wasn’t nearly as quiet as I was hoping for.

I work with high quality microphones for my recording studio, so they can pick up any noise that I can hear. I’ve settled on turning off most of my external drives while recording videos. Ejecting the drives and unplugging the Thunderbolt cable or turning off the power on the Thunderbay 4 did the trick – ultra quiet.

Sound Test

I recorded around 10 seconds of audio with the ambient room noise, which gives you a baseline for the noise in my office. I used my iPhone 6+ to record the audio with the Voice Memos app.

It's hard to demonstrate how a device sounds, since the sound from your speakers is going to be different depending on the speakers, sound level, and recording device I used. I tested these sound clips side by side with the devices to gauge what they sounded like.

1. Listen at 50% volume on the iPhone/Mac to get a similar sound to my office.

2. Listen to the Thunderbay 4 Mini SSD at 50% volume on iPhone/Mac for a similar sound profile.

3. Listen to the Thunderbay 4 HDD at a 75% volume on iPhone/Mac to get a similar sound profile. This recording felt quieter than what I heard at 50% volume when I compared the audio to the actual device.

SoftRAID - RAID managed in software

The Thunderbay drives use a software raid, named SoftRAID, to configure the drives and monitor the disk health. This provides some benefits over hardware RAID in that operations can leverage the multiple cores in your Mac to do parallel operations. In theory this makes setup and configuration faster.

Out of the box, both RAID drives were setup with RAID 5, and I found when I wanted to change that it was a little confusing. The software provides a guide, but I found it overwhelming with where to start. These drives are more oriented to a professional, and less so a general consumer. It requires more education to understand the RAID configurations and some of the best practices.

Don’t remove a drive, unless it fails – I found out the hard way after a photo shoot. I had one issue with SoftRAID not recognizing my drives or the RAID arrays after I pulled out a drive for photos. An error message recommended restarting my Mac – after rebooting the Mac Pro everything was back to normal. OWC says that removing two drives will cause it to rebuild the RAID volume.

If you don’t need to change anything, keeping the RAID 5 setup seems to be the way to go.

Black Magic Disk Speed Test

I like the Black Magic Disk Speed Test because it really provides a more realistic view into how fast a drive is for read and write performance. It uses compressed data, which simulates what you would find when working with video files.

I wasn’t able to get the RAID 0 advertised performance of 1346 MB/s on the Thunderbay 4 Mini SSD. In my tests I was able to get around 1218 MB/s read speeds and 1082.9 MB/s write speeds.

For the Thunderbay 4 HDD I wasn’t able to get the 790 MB/s advertised speed, which I assume was in RAID 0, not the RAID 5 that I used on the Thunderbay 4. In my testing I found the read speed to be around 537.4 MB/s and the write speed around 533.8 MB/s.

The posted limits on OWC’s website seem higher than my testing with Black Magic Disk Speed test. I haven’t heard back from OWC on how they benchmarked their drive performance.

WD My Book Thunderbolt Duo RAID 1

  • 103.4 MB/s write

  • 104.9 MB/s read

Thunderbay 4 12TB HDD RAID 5

  • 533.8 MB/s write

  • 537.4 MB/s read

Mac Pro 2013 512GB Flash No RAID

  • 881.3 MB/s write

  • 947.7 MB/s read

Thunderbay 4 Mini SSD RAID5

  • 538.7 MB/s write

  • 945.5 MB/s read

Thunderbay 4 Mini SSD RAID 0

  • 1082.9 MB/s write

  • 1218.0 MB/s read

File Copy Write Speed Test

I did a quick real world test where I copied a moderate sized Final Cut Pro project from my Mac Pro’s internal Flash drive to the external disk drives. The test was setup to emulate how I work with video projects, which gives you an example look outside the Black Magic Disk test.

I copied a 13.83 GB Final Cut Pro project bundle, which contains numerous folders containing the source video files as well as the rendered video files. 

It was the fastest on the Thunderbay 4 Mini SSD RAID 5, writing 929 MB/s in 15.1 seconds. To give perspective the slowest time was on the WD My Book Thunderbolt Duo RAID 1 – writing 113.1 MB/s over 122.3 seconds (2 minutes 2.3 seconds). SSD drives are very fast

WD My Book Thunderbolt Duo RAID 1

  • 122.31 seconds
  • 113.1 MB/s write

Thunderbay 4 12TB HDD RAID 5

  • 27.6 seconds
  • 502.1 MB/s

Thunderbay 4 Mini SSD RAID 5

  • 20.4 seconds
  • 679.1 MB/s

Thunderbay 4 Mini SSD RAID 0

  • 15.1 seconds
  • 919.1 MB/s

OWC Support

I asked a ton of questions in my search for a Thunderbolt drive, OWC’s CEO Larry and team were very helpful in answering all of my beginner questions. Without their help I wouldn’t have been able to review and test a faster Thunderbolt external hard drive.

Final Thoughts

Both drives were great for performance and space. My internal Mac Pro 2013’s 512 GB drive has been feeling tight for the past year, and a faster external drive has been something that I have been searching for.

Both drives provided the redundancy that I was looking for, along with the speed, and space. I really enjoyed the form factor of the Thunderbay 4 Mini, but I want more storage space – which makes me favor the Thunderbay 4.

Thunderbay 4 Mini RAID with 4TB SSD

Pros

  • Very Fast in RAID 0 (1082.9 MB/s write, 1218.0 MB/s read)
  • Fast in RAID 5 (538.7 MB/s write, 945.5 MB/s read)
  • Quieter (not silent)
  • Small and light

Cons

  • More expensive per TB ($2,349)
  • Less disk space (4 TB max)

Thunderbay 4 RAID with 12TB HDD

Pros

  • Lots of disk space (up to 32 TB)
  • Fast in RAID 5 (533.8 MB/s write, 537.4 MB/s read)
  • Less expensive per TB ($979)

Cons

  • Noisier with 4 disks spinning + fan
  • Bigger + heavier

Product Links

Disclaimer: I was loaned two Thunderbay review units (4TB SSD Mini + 12TB HDD) for this text and video review in my search for real world performance. OWC offers a discount on hardware for product reviews.

Posted on June 23, 2015 and filed under Reviews.

Swift vs. Objective-C: 10 reasons the future favors Swift

It’s high time to make the switch to the more approachable, full-featured Swift for iOS and OS X app dev

 

Programming languages don’t die easily, but development shops that cling to fading paradigms do. If you're developing apps for mobile devices and you haven't investigated Swift, take note: Swift will not only supplant Objective-C when it comes to developing apps for the Mac, iPhone, iPad, Apple Watch, and devices to come, but it will also replace C for embedded programming on Apple platforms.

Thanks to several key features, Swift has the potential to become the de-facto programming language for creating immersive, responsive, consumer-facing applications for years to come.

Read all 10 reasons for Swift on InfoWorld.

Posted on May 28, 2015 and filed under News.