• 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 19:01:03 +0100

On Saturday, February 23, 2002, at 05:46 PM, Peter Schols wrote:

Hi,

My app has a matrix containing 7 buttons. When the user clicks a button, I need to know which buttons are ON. I tried the following code, but my app crashes when executing this method.

Running it in the debugger should tell you a lot more.

What am I doing wrong here?

Plenty; you don't initialize i, you allocate an NSArray and leak it, you don't increment i in the loop...

- (NSString *)setDay:(id)sender
{
int i=0;
NSArray* array = [dayButton selectedCells];
for (i =0; i< [array count];i++) {
if ([[array objectAtIndex:i] state] == NSOnState) {
// code to add the Tag of the selected item to another array goes here }
}
}

The whole method looks suspect to me --- why [dayButton selectedCells], for example --- but it is difficult to tell without the context.

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: 
 >Getting selected items in a matrix (From: Peter Schols <email@hidden>)

  • Prev by Date: Re: number formatting
  • Next by Date: Re: Getting selected items in a matrix
  • Previous by thread: Re: Getting selected items in a matrix
  • Next by thread: Getting selected items in a matrix
  • Index(es):
    • Date
    • Thread