• 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
[self class] broken for clusters?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[self class] broken for clusters?


  • Subject: [self class] broken for clusters?
  • From: Kirk Kerekes <email@hidden>
  • Date: Thu, 15 Sep 2005 22:25:57 -0500

I've been using -[[[self class] alloc] initWith...] in categories on class clusters for literally years, but suddenly it seems to be broken.

Or I am.

Example:

Drop the following into a pristine "Foundation Tool" project's main ():, and build with XCode 2.x.

        // create a concrete instance of class cluster
    id thing = [NSString stringWithString: @"test"];
    id newThing;

        // get class object.
    Class thingclass = [thing class];

// confirm that factory object responds as per documentation...
NSLog(@"responds: %@",
[thingclass respondsToSelector: @selector(stringWithString:)] ? @"YES": @"NO");
// returns YES every doggone time, just like it oughta.



//generates the following exception here:
/*
<NSInvalidArgumentException> *** initialization method - initWithCharactersNoCopy:length:freeWhenDone: cannot be sent to an abstract object of class NSCFString: Create a concrete instance!
*/
newThing = [thingclass stringWithString: thing];



This used to work. I've been using it for years.

But it doesn't appear to work any more.

The exception happens with all class-clusters that I have tried (NSString, NSArray, NSDictionary).
It happens with the latest version of XCode, where latest is defined as a version we are technically not supposed to discuss in a public list. But I don't _think_ that this is an XCode issue.


It happens with every permutation of OS SDK and GCC version that I have tried. (10.4,10.4u,10.3.9, GCC4, GCC3.3)

The whole goal of class clusters is to conceal implementation complexity behind a facade of simplicity. Manifestly, a NSString class object should _not_ return an instance which does not perform as an NSString.

Right?

And sending -class to an NSString instance should return something that works as an NSString class object, because that is the documented behavior of -class.

But it doesn't. It returns something that _says_ it works (respondsToSelector:), then doesn't.

SO, am I deranged, or is this a bug? (I could be deranged -- I am ill and moderately feverish at the moment)

And if it is not a bug, why not?

_______________________________________________
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: [self class] broken for clusters?
      • From: Kirk Kerekes <email@hidden>
  • Prev by Date: Re: Playing SWF Movies
  • Next by Date: Re: `NSTask' and child processes
  • Previous by thread: Re: Keeping windows hidden
  • Next by thread: Re: [self class] broken for clusters?
  • Index(es):
    • Date
    • Thread