Re: [Extreme Newbie] Cannot find class (factory) method
Re: [Extreme Newbie] Cannot find class (factory) method
- Subject: Re: [Extreme Newbie] Cannot find class (factory) method
- From: Chris Gehlker <email@hidden>
- Date: Thu, 06 Sep 2001 09:02:32 -0700
On 9/6/01 7:51 AM, "Paul Carvill" <email@hidden> wrote:
>
Hello all,
>
>
Please can someone tell me what's gone wrong here. I've got two objects -
>
one's a controller that manages the interface and actions, the other simply
>
multiplies two variables and returns the result.
>
>
the line:
>
>
total = [twice multiply:x by:y];
>
>
when built gives the warning:
>
>
cannot find class (factory) method.
>
return type for "multiply:by:" defaults to id
>
assignment makes integer from pointer without a cast
>
>
>
Any help would be very appreciated. Apologies for my staggering
>
newbie-ness.
It looks like "twice" is a class name even though you didn't follow the
convention of starting it with a capital letter. But multiply:by: is an
instance method, i.e. It's defined as:
- (int)multiply:(int)x by:(int)y;
Rather than
+ (int)multiply:(int)x by:(int)y;
So the first line is telling you that there is no +multiply method
The next line is telling you that the the compiler is defaulting to the
return type (id)
The last line is complaining that you are assigning this assumed id to an
int.
Try this:
Twice *myTwice = [[[Twice alloc] init] autorelease];
total = [myTwice multiply:x by:y];
...
--
Cogito Ergo Spud. - I think therefore I yam.