我创建了一个自定义的类,它显示时间日期格式,我需要像法的定时器来更新秒,所以这里是我的代码:更新NSDateFormatter用的NSTimer
CustomClass.m
- (NSString *) showLocaleTime {
NSDateFormatter *timeFormater = [[NSDateFormatter alloc] init];
timeFormater = [setDateFormat:@"HH:mm:ss "];
NSString *currDay = [timeFormater stringFromDate:[NSDate date]];
currDay = [NSString stringWithFormat:@"%@",currDay];
[timeFormater release];
return timer;
}
- (void) updateLocaleTime {
[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(showLocaleTime) userInfo:nil repeats:YES];
}
viewController.m:
CustomClass *time = [[CustomClass alloc]init];
label.text = [time showLocaleTime];
[time updateLocaleTime];
但问题是updateLocaleTime
不叫更新秒!我错过了什么吗? 谢谢
有没有办法像我说的那样调用这个方法? :-s我需要它,它的公共API给我的朋友我需要它非常简单 – 2012-01-12 13:03:28
正如爱因斯坦所说,一切都应该尽可能简单,但并不简单。 – 2012-01-12 13:29:15
谢谢,但我收到了'SIGABRT' !!? – 2012-01-12 13:52:54