Re: -(NSString *)description method not called in Cocoa app
Re: -(NSString *)description method not called in Cocoa app
- Subject: Re: -(NSString *)description method not called in Cocoa app
- From: Brian Andresen <email@hidden>
- Date: Sun, 19 Dec 2004 21:15:17 -0800
On Sun, 19 Dec 2004 23:03:09 -0500, The Karl Adam <email@hidden> wrote:
> What is your init routine and did you actually implement the
> description method? The only way it would print that NSObject default
> is if you didn't properly initialize your object, or somewhere in it's
> handling you created an NSObject instead of MyObject. In either case
> we need more infor to tell you what's wrong.
Yup, I did implement -description (and note that in my CLI-only app,
it works great). I have exactly one init routine:
- (id)initWithString:(NSString *)string
{
self = [super init];
if ( ! self )
return nil;
[... set various instance variables ...]
return self;
}
If I call [obj description] on the object just after it's been alloc'd
and init'd, the description comes out right -- even in the Cocoa app!
Immediately after I add all these objects to the NSArray, I can do:
MyObject* obj = [theArray objectAtIndex:0];
NSLog( @"%@", [obj description] );
and it comes out right. But I do the same thing at some point later,
and it comes out with the generic answer. It does say "MyObject" not
"NSObject" when it writes the description and memory address... I
don't know if that's worth anything.
I tried implementing a basic -init method too, but that didn't change
any of the effects.
So it seems... something changed between when I added the objects into
the array (which is itself an instance variable) and when I'm reading
them out. In the debugger, the instances show up as the proper type,
as my subclass. What else might I check?
Thanks,
-Brian
_______________________________________________
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