Forked from almostintuitive/NSHashTable+SequenceType.swift
Created
September 28, 2015 09:07
-
-
Save onmyway133/86dece46817529b4ee8c 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