• 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: best way to test for NSString / NSCFString type of object?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: best way to test for NSString / NSCFString type of object?


  • Subject: Re: best way to test for NSString / NSCFString type of object?
  • From: Greg Titus <email@hidden>
  • Date: Thu, 2 Oct 2003 18:21:27 -0700

On Friday, October 3, 2003, at 10:32 AM, Ben Dougall wrote:
if( [[[array lastObject] className] isEqual:@"NSString"] ) {
...
On Thursday, October 2, 2003, at 05:54 PM, Greg Hulands wrote:
why not do [[array lastObject] class] == [NSString class]

Because that will only work if the object is _exactly_ an NSString instance, and not one of its subclasses. Since NSString is the virtual base class of a class cluster, you will never see an actual NSString instance, so this will never work.

The other suggestions of using -isKindOfClass: is the correct thing to do. (-isKindOfClass: sees if the object is an instance of the class or any subclass).

- Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: best way to test for NSString / NSCFString type of object? (From: Greg Hulands <email@hidden>)

  • Prev by Date: Re: best way to test for NSString / NSCFString type of object?
  • Next by Date: Re: Command Key physical key down
  • Previous by thread: Re: best way to test for NSString / NSCFString type of object?
  • Next by thread: Trivial NSOpenPanel Question...
  • Index(es):
    • Date
    • Thread