开发者

'updateTimer' undeclared (first use in this function)

开发者 https://www.devze.com 2023-04-09 20:50 出处:网络
I get this error \'\'updateTimer\' undeclared (first use in this function)\' This is the code: #import <UIKit/UIKit.h>

I get this error ''updateTimer' undeclared (first use in this function)'

This is the code:

#import <UIKit/UIKit.h>


@interface SleepAppFinalViewController : UIViewController
{

    //IBOutlet UILabel *myLabel;

    IBOutlet UILabel *_label;
    NSTimer *timer;

}

-(void)updateTimer;

.m

@implementation SleepAppFinalViewController

-(void)updateTimer {

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"hh:mm:ss"];
    _label.text = [formatter stringFromDate:[NSDate date]];
    [formatter release];
}

- (void)viewDidLoad
{
    timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:(u开发者_开发百科pdateTimer) userInfo:nil repeats:YES];
    [super viewDidLoad];


}

The error is on the viewdidload line of 'timer'


It should be @selector(updateTimer) instead of (updateTimer).


- (void)viewDidLoad
{
    timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateTimer) userInfo:nil repeats:YES];
    [super viewDidLoad];


}
0

精彩评论

暂无评论...
验证码 换一张
取 消