Iphone 选择器'的类方法未知;scheduledTimerWithTimeInterval带计时器
通过阅读这里的其他帖子,我试图弄明白这一点,但到目前为止我还没有弄明白任何事情。 如果只是一个新手,不理解我需要建立的联系,或者如果我没有任何关联,我不知道 我正在制作一个iPhone应用程序,里面有两个计时器 我正在努力使计时器的源代码正常工作 我使用xcode中的反向应用程序模板,因为我想在以后的设置中使用反向应用程序模板(您可以自定义计时器) 在my MainViewController.h中:Iphone 选择器'的类方法未知;scheduledTimerWithTimeInterval带计时器,iphone,ios,objective-c,cocoa-touch,selector,Iphone,Ios,Objective C,Cocoa Touch,Selector,通过阅读这里的其他帖子,我试图弄明白这一点,但到目前为止我还没有弄明白任何事情。 如果只是一个新手,不理解我需要建立的联系,或者如果我没有任何关联,我不知道 我正在制作一个iPhone应用程序,里面有两个计时器 我正在努力使计时器的源代码正常工作 我使用xcode中的反向应用程序模板,因为我想在以后的设置中使用反向应用程序模板(您可以自定义计时器) 在my MainViewController.h中: #import "FlipsideViewController.h" #import "UIK
#import "FlipsideViewController.h"
#import "UIKit/UIKit.h"
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate, UIPopoverControllerDelegate> {
IBOutlet UILabel *timerP1;
IBOutlet UILabel *timerP2;
NSTimer *myTimerP1;
NSTimer *myTimerP2;
}
- (IBAction)startP1;
- (IBAction)stopP1;
- (IBAction)resetP1;
- (void)showActivityP1;
- (IBAction)startP2;
- (IBAction)stopP2;
- (IBAction)resetP2;
- (void)showActivityP2;
@property (strong, nonatomic) UIPopoverController *flipsidePopoverController;
@end
我得到错误“选择器的未知类方法”scheduledTimerWithTimeInterval:target:selector:userinfo:repeats:'
我做错了什么
我做错了什么
坦白说,你做错的是没有使用自动补全。
这是个小错误,没什么好担心的
userinfo
应该是userinfo
(注意大写字母I
)
因此,完整的调用变成:
[NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(showActivityP1)
userInfo:nil
repeats:YES];
哦,顺便说一句,-(void)showActivityP1;{…}
也会给你带来麻烦,放下;
非常感谢:)我会尝试更多地使用自动完成功能,只是需要习惯它
[NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(showActivityP1)
userInfo:nil
repeats:YES];