Conor Taylor
Conor Taylor

Reputation: 3108

Passing values to a method in a different class - Objective C

I have two classes: Drawing and Game. In Drawing there is a class called redraw, which appears as follows:

- (void) redraw:(int)x:(int)y {

Now, there are many other methods in Drawing which to not require values to be passed to it, and I can even call them from Game using the following code: [drawing callSomeMethod];.

(By the way, drawing is created in Game.m, like this: Drawing *drawing.

I would have assumed that in the redraw method above, to call that from Game all i'd have to do it write: [drawing someMethod(val1, val2)];, but I keep getting the following error: No visible @interface for 'Drawing' declares the selector 'redraw:'"

How can I pass val1 and val2 (defined in Game.m) to a method in Drawing.m?

Upvotes: 1

Views: 883

Answers (1)

J Shapiro
J Shapiro

Reputation: 3861

Make sure this method is declared in Drawing.h

- (void) redraw:(int)x:(int)y;

Once that's done, this will work:

Drawing *drawing = [[Drawing alloc] init];
[drawing redraw:3:5]; // where 3 and 5 are whatever x and y values you choose.

Upvotes: 2

Related Questions