• 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: object type testing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: object type testing
      • From: Boyd Collier <email@hidden>
References: 
 >Re: object type testing (From: Boyd Collier <email@hidden>)

  • Prev by Date: Re: filling NSImage with binary data from NSData
  • Next by Date: Re: filling NSImage with binary data from NSData
  • Previous by thread: Re: object type testing
  • Next by thread: Re: object type testing
  • Index(es):
    • Date
    • Thread