• 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: Ben Dougall <email@hidden>
  • Date: Mon, 8 May 2006 13:09:16 +0100


On Sunday, May 7, 2006, at 08:33 pm, Ben Dougall wrote:

right, thanks for the answers. i'm going to switch to isMemberOfClass rather than compare pointers just to be safe -- isKindOfClass definitely isn't what i need here. cool, thanks.

instead of using isMemberOfClass or comparing pointers how should i do it a more polymorphic friendly way?


i'm extracting info from data that's in a particular format. the data format has a small number of elementary data types. i have an objective-c class per data type. the data i'm parsing has a grammar. e.g. once a data element of type X occurs the type Y should follow it. that's where the isMemberOfClass or pointer comparison comes in:

if( [dataElementThatFollowedElementOfDataTypeX class] != [DataTypeY self] ) {
// error in data: the data being parsed is malformed
} else {
// do stuff with dataElementThatFollowedElementOfDataTypeX knowing it's of the right type
}


should i just have a same named method on every object that responds with what type of object it is? say like:

// method that every data type object has:
- (unsigned char)type;


if( [dataElementThatFollowedElementOfDataTypeX type] != 'Y' ) { ...


better?

thanks, ben.

_______________________________________________
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


References: 
 >Re: object type testing (From: Ben Dougall <email@hidden>)

  • Prev by Date: Re: Which format for image file resources in Cocoa application?
  • Next by Date: Re: Oversight? TableViews ignoring Home and End keys?
  • Previous by thread: Re: object type testing
  • Next by thread: Re: object type testing
  • Index(es):
    • Date
    • Thread