Rob Smythe
Rob Smythe

Reputation: 429

Function undeclared error

Can you spot the error, please? Why does the compiler think my function is undeclared? Thanks. -Rob

In .h file

-(int) getW:(int)xPosition;

In .m file

-(int) getW:(int)xPosition {
    return (xPosition-58)/48; 
}

in another procedure, the call to the function:

whichTile=[getW: xPosition] ;   <----ERROR getW undeclared (first use in this function)

(xPosition and whichTile have been declared as integers, and in use earlier in the procedure). I tried it with (NSInteger), too (and a million other permutations!). Thanks for you help.-Rob

Upvotes: 0

Views: 100

Answers (1)

justin
justin

Reputation: 104698

you have declared an instance method and called it without specifying the instance.

for example:

whichTile = [self getW:xPosition];
-or-
whichTile = [anObject getW:xPosition];

unlike other languages, self is not implicit when messaging.

Upvotes: 1

Related Questions