Re: object type testing
Re: object type testing
- Subject: Re: object type testing
- From: Boyd Collier <email@hidden>
- Date: Sun, 7 May 2006 18:40:15 -0700
Thanks very much for the feedback.
Erik, I don't mind at all being picked on. I've lots of experience
with rather old-fashioned procedural programming and have to get over
old ways of thinking about things and I've lots to learn about OOP.
Uli, I like the simplicity of your suggestion and will put it to use
(not that Erik's suggestion isn't a good one, too, and I'll certainly
study it closely to make sure that I understand it).
Boyd
On May 7, 2006, at 2:47 PM, Uli Kusterer wrote:
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