migrate to -[NSArray firstObject] for safety

Using `-[NSArray firstObject]` will return nil on an empty array while `-[NSArray objectAtIndex:0]` will throw an `NSRangeException`.

Xcode  | OS X | iOS
------------- | ------------- | ------------- 
Xcode 5.0+  | 10.6+ | iOS 4+

See the `-[NSArray firstObject]` documentation for [OS X](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/index.html#//apple_ref/occ/instm/NSArray/firstObject) and [iOS](https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/index.html#//apple_ref/occ/instm/NSArray/firstObject) for more detail.
This is what is causing the PR no longer be auto-mergable, as I changed it to use [lastObject](f3302ee14d114c), related to discussions in #566.