怎么按照hr:min:sec的格式计算时间这是我的计算器的代码:-(IBAction)start{ timer1= [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(timepassed) userInfo:nil repeats:YES]; }-(void)timepassed{ counter++; i

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/16 01:55:47
怎么按照hr:min:sec的格式计算时间这是我的计算器的代码:-(IBAction)start{ timer1= [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(timepassed) userInfo:nil repeats:YES]; }-(void)timepassed{ counter++; i

怎么按照hr:min:sec的格式计算时间这是我的计算器的代码:-(IBAction)start{ timer1= [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(timepassed) userInfo:nil repeats:YES]; }-(void)timepassed{ counter++; i
怎么按照hr:min:sec的格式计算时间
这是我的计算器的代码:-(IBAction)start{ timer1= [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(timepassed) userInfo:nil repeats:YES]; }-(void)timepassed{ counter++; if(sec==60) sec=0; else sec=counter/100; if(min==60) min=0; else min=sec/60; if(hr==24) hr=0; else hr=min/60; m1++; NSString *l=[NSString stringWithFormat:@"%i:%i:%i",hr,min,sec]; [m setText:l];}有什么错误的地方么?

怎么按照hr:min:sec的格式计算时间这是我的计算器的代码:-(IBAction)start{ timer1= [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(timepassed) userInfo:nil repeats:YES]; }-(void)timepassed{ counter++; i
-(void) timepassed{ counter++; if (counter== 60) { secs++; counter= 0; } if (secs== 60) { min++; secs= 0; } if (min== 60) { hr++; min= 0; } // Your usual output here} 查看原帖>>
求采纳