I\'m trying to iterate over an instance of NSOrderedSet. Something like this:
func myFunc() {
var orderedSet = NSOrderedSet(array: [ 42, 43, 44])
for n
You can iterate over an ordered set with
let orderedSet = NSOrderedSet(array: [ 42, 43, 44])
orderedSet.enumerateObjectsUsingBlock { (elem, idx, stop) -> Void in
println("\(idx): \(elem)")
}
UPDATE: As of Swift 1.2 (Xcode 6.3), NSOrderedSet
conforms to
SequenceType
and can be enumerated with for ... in ...
:
let orderedSet = NSOrderedSet(array: [ 42, 43, 44])
for elem in orderedSet {
println(elem)
}