NSIndexSet indexGreaterThanOrEqualToIndex
- (NSUInteger)indexGreaterThanOrEqualToIndex:(NSUInteger)index
Parameters
index
Index being inquired about.
Return Value of [NSIndexSet indexGreaterThanOrEqualToIndex]
Closest index in the index set greater than or equal to index; NSNotFound when the index set contains no qualifying index.
NSIndexSet indexGreaterThanOrEqualToIndex example.
Usually, you enumerate through the indexes in a set like so:
NSUInteger idx = [theSet indexGreaterThanOrEqualToIndex: 0];
while (idx != NSNotFound) {
// idx equals the next index in the set.
idx = [theSet indexGreaterThanIndex: idx];
}
NSUInteger idx = [theSet indexGreaterThanOrEqualToIndex: 0];
while (idx != NSNotFound) {
// idx equals the next index in the set.
idx = [theSet indexGreaterThanIndex: idx];
}
Example of [NSIndexSet indexGreaterThanOrEqualToIndex].
@interface IKImageBrowserView (event)
- (void)mouseDown:(NSEvent *)theEvent ;
@end
@implementation IKImageBrowserView (event)
- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint pt = [self convertPoint: theEvent.locationInWindow fromView: nil];
NSInteger index = [self indexOfItemAtPoint:pt] ;
if ( index != NSNotFound )
{
NSUInteger ge ;
NSUInteger le ;
NSIndexSet* set = [self selectionIndexes] ;
NSMutableIndexSet* mutableSet = [[NSMutableIndexSet alloc] init] ;
[mutableSet addIndexes:set] ;
ge = [mutableSet indexGreaterThanOrEqualToIndex:index] ;
le = [mutableSet indexLessThanOrEqualToIndex:index] ;
if ( (ge == le) && (ge != NSNotFound) )
{
[mutableSet removeIndex:index] ;
}
else
{
[mutableSet addIndex:index] ;
}
[self setSelectionIndexes:mutableSet byExtendingSelection:NO] ;
// [ mutableSet release ];
}
}
@end
- (void)mouseDown:(NSEvent *)theEvent ;
@end
@implementation IKImageBrowserView (event)
- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint pt = [self convertPoint: theEvent.locationInWindow fromView: nil];
NSInteger index = [self indexOfItemAtPoint:pt] ;
if ( index != NSNotFound )
{
NSUInteger ge ;
NSUInteger le ;
NSIndexSet* set = [self selectionIndexes] ;
NSMutableIndexSet* mutableSet = [[NSMutableIndexSet alloc] init] ;
[mutableSet addIndexes:set] ;
ge = [mutableSet indexGreaterThanOrEqualToIndex:index] ;
le = [mutableSet indexLessThanOrEqualToIndex:index] ;
if ( (ge == le) && (ge != NSNotFound) )
{
[mutableSet removeIndex:index] ;
}
else
{
[mutableSet addIndex:index] ;
}
[self setSelectionIndexes:mutableSet byExtendingSelection:NO] ;
// [ mutableSet release ];
}
}
@end