Created
September 19, 2015 18:33
-
-
Save almostintuitive/89e99c9c31f9830260db to your computer and use it in GitHub Desktop.
Use NSHashTable with for .. in .. style enumeration with Swift2 (safely)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSHashTable: SequenceType { | |
public func generate() -> AnyGenerator<AnyObject> { | |
var array = self.allObjects | |
var nextIndex = array.count-1 | |
return anyGenerator { | |
if (nextIndex < 0) { | |
return nil | |
} | |
return array[nextIndex--] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment