我的計劃是這樣的:如何在init方法中調用方法?
-(id)init
{
if ((self = [super init]))
{
//TargetWithActions *targetActions= [[TargetWithActions alloc] init];
[self countDownSpeed123];
}
return self;
}
-(void)countDownSpeed123
{
countDownSpeed = 5.0f;
}
@end
警告:「TargetWithActions」不能爲「-countDownSpeed123」
我收到這樣的警告做出迴應。我的程序中哪裏出錯了。請解釋 ? 謝謝。
如果我需要在另一個類中使用countDownSpeed值,該如何保留該值?我如何在其他課堂上使用?我認爲保留適用於指針類型。
編輯:
對不起,我的壞的編碼和疏忽。我的程序中犯了一些非常直截了當的錯誤。
感謝您的回答。
- 第一:我沒有 接口聲明 功能(
-(void)countDownSpeed123;
)。 第二:我沒有在我的課程中包含 以下需要 (countDownSpeed)值。現在
TargetWithActions *targetActions= [[TargetWithActions alloc] init]; [targetActions countDownSpeed123];
,我得到了我所需要的。
謝謝。
您是否記得在界面中聲明「countDownSpeed123」? – 2010-04-02 05:41:20
需要比這更多。請提供界面,而不僅僅是實現。 – 2010-04-02 05:42:57
對不起,我忘了在界面中聲明它。 謝謝。編寫該方法的更好方法是哪一種。使用(id)或(void)? – 2010-04-02 05:48:25