Re: A category for NSMatrix?
Re: A category for NSMatrix?
- Subject: Re: A category for NSMatrix?
- From: Chris Gehlker <email@hidden>
- Date: Wed, 12 Sep 2001 12:41:10 -0700
On 9/12/01 2:17 AM, "Rafael K. Kobylinski" <email@hidden> wrote:
>
Hello List,
>
>
I am new to Objective-C and Cocoa and working my way through the
>
O'Reilly book. In Chapter 13, the author defines a simple utility
>
function clearButtonMatrix - I was wondering whether this really
>
should be rather implemented in a new category for NSMatrix (as the
>
concept of categories is new to me, I am not quite sure what the
>
implications would be).
I think a static helper function is fine here. The reason not to use a
category is you really aren't extending the functionality of NSMatrix. You
are just clearing a particular kind of NSMatrix, a column of radio buttons.
A static helper function lets everybody know that this only makes sense in
the context of this infoWindowController. A category should make sense for
every NSMatrix.
>
The function is defined as follows:
>
>
void clearButtonMatrix(id matrix)
>
{
>
int i, rows, cols;
>
[matrix getNumberOfRows: &rows columns: &cols];
>
for (i = 0; i < rows; i++)
>
[[matrix cellAtRow: i column: 0] setState: NO];
>
}
>
>
I noticed that the input paremter is typed to id rather than
>
NSMatrix, although it seems to me that this function is always called
>
with a NSMatrix.
Not only should the argument be an NSMatix*, NO should be NSOffState. It's
this kind of sloppiness that really detracts from "Learning Cocoa."
--
Cogito Ergo Spud. - I think therefore I yam.