2010-06-19 23 views
0

我有一個方法可以調用帶有1個參數的另一個方法到另一個類。它可以正常使用,但現在我需要1個更多的參數,這是我的代碼:obj-c:iphone編程,帶有2個參數的調用方法

我得到一個「ADDOBJECT可能不響應」

test.m

調用方法:

DrunkeNewIdeaAppDelegate *appDelegate = (DrunkeNewIdeaAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    Testes *myLevelObject = (Testes *)appDelegate.testViewController1; 
    [myLevelObject addobject:rephereanswer,nbimportant]; 

方法叫做:

testes.h

-(void)addobject:(double)rephereanswer:(double)nbimportant; 

testes.m

-(void)addobject:(double)rephereanswer:(double)nbimportant{ 

回答

1

你的方法的簽名實際上是addObject: :。參數之間用冒號之前,所以你打電話給你的方法,像這樣:

[myLevelObject addobject:rephereanswer :nbimportant]; 

然而,在Objective-C,流行的風格是命名所有的參數,所以你可能要改變你的方法是:

- (void)addobject:(double)rephereanswer otherParam:(double)nbimportant; 

在這種情況下,你會這樣稱呼它:

[myLevelObject addobject:rephereanswer otherParam:nbimportant]; 

(A更具描述性的名字比我otherParam也是可取的。)

2

試試這個

[myLevelObject addobject:rephereanswer :nbimportant]; 
+0

好像在工作thx – hugo411 2010-06-19 22:10:05