Skip to content

Instantly share code, notes, and snippets.

@tonyarnold
Created July 6, 2014 05:10
Show Gist options
  • Save tonyarnold/78bee7dd76557cdef69f to your computer and use it in GitHub Desktop.
Save tonyarnold/78bee7dd76557cdef69f to your computer and use it in GitHub Desktop.
Originally proposed and provided by Rob Rix allows you to append values from an NSArray to a Swift array, so long as they match the Swift array's expected element type.
import Foundation
@assignment func += <T:AnyObject> (inout array: T[], cocoaArray: NSArray) {
array.extend(
map(cocoaArray) {
$0 as T
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment