Re: object type testing
Re: object type testing
- Subject: Re: object type testing
- From: Uli Kusterer <email@hidden>
- Date: Sun, 7 May 2006 23:47:42 +0200
Am 07.05.2006 um 21:53 schrieb Boyd Collier:
- (IBAction)doGroupsChecks:(id)sender {
if ([sender isMemberOfClass:[NSMatrix class]]) {
// find out which button was hit by calling [onButton tag] and
do appropriate stuff
...
}
if ([sender isMemberOfClass:[NSButton class]]) {
// do stuff to keep track of which check box was hit
...
}
}
In my simple testing, the above seems to work as I expect and has
the (small) advantage of not having to worry about mixing up tags
used to distinguish different radio buttons in that set with tags
used for my check boxes. But having read the various messages on
this topic, I'm wondering whether (1) I'm going to get into trouble
by using isMemberOfClass, and (2) whether, in my inexperience with
cocoa, I'm totally overlooking an entirely different and more
straightforward approach.
Why not just create two separate methods, one for radios and one
for checkboxes and set the actions accordingly? Then the objects
themselves will "tell you" what kind of object they are and you don't
have to do this comparison at all.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden