Re: NSObject description not working
Re: NSObject description not working
- Subject: Re: NSObject description not working
- From: matt neuburg <email@hidden>
- Date: Sat, 31 Jan 2004 17:42:48 -0800
On Fri, 30 Jan 2004 02:33:16 -0500, Eric Wang <email@hidden> said:
>
on 1/10/04 11:20 PM, matt neuburg at email@hidden wrote:
>
>
> 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.
>
>
>
It seems that when using bindings, a class that is being observed
>
is replaced by a custom subclass NSNotifying_YourClassNameHere at runtime.
>
That subclass implements -description to print out the object address, thus
>
overriding your class's description method,
Is this worth a bug report? Personally I would prefer a MyObject to behave
like a MyObject, not like some other object merely because an
NSArrayController put it into the array... 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.