• 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
NSObject description not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSObject description not working


  • Subject: NSObject description not working
  • From: matt neuburg <email@hidden>
  • Date: Sat, 10 Jan 2004 20:20:55 -0800

The following code shows the problem. The first two parts are just warm-up, to
show what *should* happen. The third part is the problem.

MyObject* obj = [[MyObject alloc] init];
NSLog([obj description]); // "howdy"

NSArray* arr = [NSArray arrayWithObject: obj];
[obj release];
obj = [arr objectAtIndex: 0];
NSLog([obj description]); // "howdy"
NSLog([[obj class] description]); // "MyObject"

NSLog([[theList objectAtIndex: 0] description]); // "<MyObject: 0x387ef0>"
NSLog([[[theList objectAtIndex: 0] class] description]); // "MyObject"

In the next-to-last line, instead of executing the description method and
returning "howdy", the object returns this thing in angle-brackets. Yet it is
a MyObject, just as before. So why is this?

The only difference that seems relevant is that theList is populated and
maintained by an NSArrayController / NSObjectController. But how could this be
relevant? If a thing is a MyObject instance, shouldn't it respond to a
MyObject instance method, no matter how it was created? m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
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.

  • Prev by Date: Re: Detecting a new application launch?
  • Next by Date: NSArrayController with Combo Boxes, etc.
  • Previous by thread: NSString's stringWithFormat
  • Next by thread: Re: NSObject description not working
  • Index(es):
    • Date
    • Thread