0

Okay so i have a problem. In xcode every time a full day passes i want the label to change. For instance if the time is 24:00:00 then i want the label to change from Monday to Tuesday; and then from tuesday to Wednesday and so on and so forth. This is all i have so far

if ([timev2.text isEqualToString: @"24:00:00"]) {
    [number setText:@"Tuesday"];

I can't use the statement

if([timev2 isEqualToString: @'48:00:00']){
   [number setText:@"wednesday"];

Because I'm using NSDaterFormatter. Can anyone tell me how to do this or how to edit my code to make it work?

4

2 回答 2

0

You can use UIApplicationSignificantTimeChangeNotification to be notified when the system clock changes to a new day while your app is running.

您可以使用 NSDateFormatter 打印工作日名称。格式说明符“EEEE”或“cccc”应该可以工作。(在某些语言中,工作日名称有两种形式;使用正确的一种取决于您的上下文。http://cldr.unicode.org/translation/date-time

于 2013-03-30T02:41:35.213 回答
0

在 NSDateFormatter 对象中,将日期格式设置为“EEEE”,您将在其中获得星期几。并且您可以在标签中显示。

NSDateFormatter* dateFormatter=[[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"EEEE"];
NSString *weekDay=[dateFormatter stringFromDate:[NSDate date]];

工作日是您想要的日子......快乐编码......

于 2013-03-30T07:31:57.673 回答