Skip to content

Commit 5893bfa

Browse files
committed
Merge pull request #55 from christopherweems/patch-1
Update NSIndexSet enumeration snippets to Swift
2 parents b337dab + 0ba6639 commit 5893bfa

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Foundation/NSIndexSet.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
The following code snippets can be used to enumerate over the indexes in an NSIndexSet:
1414

1515
// Forward
16-
NSUInteger currentIndex = [set firstIndex];
17-
while (currentIndex != NSNotFound) {
16+
var currentIndex = set.firstIndex
17+
while currentIndex != NSNotFound {
1818
...
19-
currentIndex = [set indexGreaterThanIndex:currentIndex];
19+
currentIndex = set.indexGreaterThanIndex(currentIndex)
2020
}
21-
21+
2222
// Backward
23-
NSUInteger currentIndex = [set lastIndex];
24-
while (currentIndex != NSNotFound) {
23+
var currentIndex = set.lastIndex
24+
while currentIndex != NSNotFound {
2525
...
26-
currentIndex = [set indexLessThanIndex:currentIndex];
26+
currentIndex = set.indexLessThanIndex(currentIndex)
2727
}
2828

2929
To enumerate without doing a call per index, you can use the method getIndexes:maxCount:inIndexRange:.

0 commit comments

Comments
 (0)