RE: nsmatrix question
RE: nsmatrix question
- Subject: RE: nsmatrix question
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Wed, 25 Jun 2003 10:34:56 -0400
>
On Tuesday, June 24, 2003, at 03:30 PM, Jeff Childers wrote:
>
>
> I have a nsmatrix of buttons. when a button in the matrix is clicked I
>
> want to know the row and column of the button.
>
>
>
> I thought it might be:
>
>
>
> //floorMatrix is the outlet for matrix
>
>
>
> [[floorMatrix selectedCell] getRow:(int *)row column:(int *)column
>
> ofCell:(NSCell *) sender];
>
>
>
> any help or leads would be useful
You are sending your message to the wrong object. You should be asking the
_matrix_ to find the cell among its cells and report back the cell's row and
column number. Instead you are asking the _cell_. How would the cell know?
If you think about who knows what, that can be very helpful in figuring out
how to form your messages.
Also, you should get familiar with the use of pointers to return more than
one value from a method or function. When you see (int *)row in the
signature that means "put the address of an integer variable here." Just
about any C book will help you learn about pointers.
You should have written:
int row, column;
BOOL foundIt = [floorMatrix getRow:&row column:&column ofCell:[floorMatrix
selectedCell]];
It's perfectly OK to leave out "BOOL foundIt =" but it does emphasize that
the method actually has a return value, which you can test.
Jonathan
_______________________________________________
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.