Last active
December 10, 2015 16:18
-
-
Save mikepj/4459727 to your computer and use it in GitHub Desktop.
A category to NSIndexSet. Only method will compare the receiver with another NSIndexSet and return a new NSIndexSet with the indices that intersect.
This file contains 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
// | |
// NSIndexSet+GSIndexSetAdditions.h | |
// | |
// Created by Mike Piatek-Jimenez on 1/4/13. | |
// Copyright (c) 2013 Mike Piatek-Jimenez. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSIndexSet (GSIndexSetAdditions) | |
- (NSIndexSet *) gsIntersectionWithIndexSet:(NSIndexSet *)otherSet; | |
@end |
This file contains 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
// | |
// NSIndexSet+GSIndexSetAdditions.m | |
// | |
// Created by Mike Piatek-Jimenez on 1/4/13. | |
// Copyright (c) 2013 Mike Piatek-Jimenez. All rights reserved. | |
// | |
#import "NSIndexSet+GSIndexSetAdditions.h" | |
@implementation NSIndexSet (GSIndexSetAdditions) | |
- (NSIndexSet *) gsIntersectionWithIndexSet:(NSIndexSet *)otherSet { | |
NSMutableIndexSet *finalSet = [[[NSMutableIndexSet alloc] init] autorelease]; | |
[self enumerateIndexesUsingBlock:^(NSUInteger index, BOOL *stop) { | |
if ([otherSet containsIndex:index]) [finalSet addIndex:index]; | |
}]; | |
return finalSet; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment