Re: NSIndexSet question
Re: NSIndexSet question
- Subject: Re: NSIndexSet question
- From: "Mark A. Stratman" <email@hidden>
- Date: Fri, 11 Jun 2004 21:22:29 -0500
I was recently facing a similar problem, and found no "Good" solution.
I ended up with something like:
unsigned int bufSize = [set count];
unsigned int *buf = (unsigned int*) malloc(sizeof(unsigned int) *
bufSize);
NSRange range = NSMakeRange([set firstIndex], ([set lastIndex]-[set
firstIndex]) + 1);
[set getIndexes:buf maxCount:bufSize inIndexRange:&range];
for (i = 0; i != bufSize; i++) {
// do stuff with buf[i], you'd probably have something like:
// [mutableTmpArray addObject:[yourArray objectAtIndex:buf[i]]];
}
free(buf);
hth,
- Mark
On Jun 11, 2004, at 7:04 PM, Glenn Zelniker wrote:
Is it possible to select the elements of an NSArray in a quick way
based on the elements of an NSIndexSet? By "quick" I mean in a way
other than traversing the index set with -firstIndex, -lastIndex, and
-indexLessThan methods. For example, suppose I have a tableView with
multiple selection enabled and I get the row indices using
NSTableView's -selectedRowIndexes method. Now, I want to use these
indices to build a new NSArray based on the objects in an arbitrary
array at the indices specified in the indexSet,
There doesn't seem to be an -(NSArray *)objectsAtIndexSet:(NSIndexSet
*)indices method for arrays. Am I missing something?
Glenn Zelniker
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.