Re: best way to test for NSString / NSCFString type of object?
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.