• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting selected items in a matrix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Getting selected items in a matrix (From: Nicholas Shanks <email@hidden>)

  • Prev by Date: Re: Getting selected items in a matrix
  • Next by Date: Re: +poseAsClass and instance variables
  • Previous by thread: Re: Getting selected items in a matrix
  • Next by thread: Re: Getting selected items in a matrix
  • Index(es):
    • Date
    • Thread