1

我有两个班级:DrawingGame。其中Drawing有一个名为 的类redraw,如下所示:

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

现在,还有许多其他方法Drawing不需要将值传递给它,我什至可以Game使用以下代码调用它们[drawing callSomeMethod];

(顺便说一下,drawing是在 中创建的Game.m,像这样:Drawing *drawing.

我会假设在上面的方法中,从我必须做的所有事情redraw中调用它 write: ,但我不断收到以下错误:Game[drawing someMethod(val1, val2)];No visible @interface for 'Drawing' declares the selector 'redraw:'"

如何将 val1 和 val2(在 中定义Game.m)传递给 中的方法Drawing.m

4

1 回答 1

2

确保在 Drawing.h 中声明此方法

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

完成后,这将起作用:

Drawing *drawing = [[Drawing alloc] init];
[drawing redraw:3:5]; // where 3 and 5 are whatever x and y values you choose.
于 2012-11-19T19:12:57.060 回答