我有一個名爲myClass的類。這個類有TouchesMoved和TouchesBegan定義。iphone - 將東西添加到類方法
這個類被其他3個類使用。但是我需要向這些類中的每一個添加更多的代碼,使其與TouchesMoved和TouchesBean方法相同,而不會覆蓋已經在其類中的代碼。我的意思是,如果我將一個TouchesBegan方法添加到三個類中的一個,它將不會使用該方法的類定義。我希望能夠代之以添加代碼而不是替換。
例子:
MyClass
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self doStuff1];
}
Object1 based on MyClass
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self doStuff2];
}
時Object1的運行的touchesBegan,它會調用doStuff2也doStuff1,而不是僅僅doStuff2。
這可能嗎?
感謝
謝謝,就是這樣。 – SpaceDog 2010-10-24 09:38:03