Re: Getting selected items in a matrix
Re: Getting selected items in a matrix
- Subject: Re: Getting selected items in a matrix
- From: John Hörnkvist <email@hidden>
- Date: Sat, 23 Feb 2002 18:54:54 +0100
On Saturday, February 23, 2002, at 06:03 PM, Nicholas Shanks wrote:
{
NSCell *currentCell;
NSEnumerator *enumerator = [[dayButton selectedCells]
objectEnumerator];
while( currentCell = [enumerator nextObject] )
{
if( [currentCell state] == NSOnState )
{
// code to add the Tag of the selected item to another
array goes here
}
}
}
If we're talking style, I'd use a trampoline and a category:
@implementation NSCell(StateQuery)
- (BOOL)hasState:(NSCellStateValue)testState
{
return [self state]==testState;
}
@end
then all you need is
selectedOnCells=[[[dayButton selectedCells] filter] hasState:
NSOnState];
or, if you just want one,
firstOnCell=[[[dayButton selectedCells] first] hasState: NSOnState];
Writing the trampolines is left as an exercise to the reader. (Although
I suppose MPWFoundation might contain them.)
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com
_______________________________________________
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.