我想我有一个概念误解,并希望得到解释。如何在“效率”目的的方法中移动代码块?
在一个类中,我有代码重复3次(和完美的工作),但要尽量使事情变得更加“高效”我把它从同一块与类内进行的方法如下:
- (void)dateUP {
NSLog(@"dateUp");
[UIView beginAnimations:@"datePicker" context:nil];
[UIView setAnimationDuration:0.5];
datePicker.transform = CGAffineTransformMakeTranslation(0,-310);
[UIView commitAnimations];
}
,然后在代码原来是,我把:
[self dateUp];
,我把我的.h如下:
-(void)dateUp;
我建立并得到这样的警告:在控制台
Line Location DetailPopUpView.m:165: warning: method definition for '-dateUp'
not found
和崩溃与此(和BTW,对的NSLog语句不显示在控制台):
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[DetailPopUpView dateUp:]: unrecognized selector sent to instance
0x3d33ef0'
任何帮助表示赞赏。我注意到的一件事是,控制台消息具有dateUp :(带有冒号),就好像参数是预期的一样。所以,最简单的解决方案就是将代码放回原处,重复3次,我想知道我做错了什么。
谢谢。
+1识趣:) – 2010-03-10 10:39:19