NSObject description not working
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.