Re: Types for the method have to conform?
Re: Types for the method have to conform?
- Subject: Re: Types for the method have to conform?
- From: Jack Nutting <email@hidden>
- Date: Thu, 11 Aug 2005 11:10:00 +0200
> In other words, instead of writing this:
>
> id foo = [[FooMatic alloc] initWithData ...];
>
> Write it like this:
>
> FooMatic *foo = [[FooMatic alloc] initWithData ...];
>
> That way the compiler knows to use the signature found in the
> FooMatic class for that method.
I don't think that will help (although doing so is a good idea in its
own right)...
The problem in this case is that +alloc returns an id, so the compiler
can't identify the recipient of -initWithData..., regardless of what
you put on the left side of the = symbol. What's needed is a cast:
FooMatic *foo = [(FooMatic *)[FooMatic alloc] initWithData...];
Another alternative is to redeclare +alloc as +(FooMatic *)alloc in
your class (although this will also generate a warning), then you
wouldn't need the cast.
--
// jack
// http://www.nuthole.com
_______________________________________________
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