这是我的代码:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];dateFormatter.dateFormat = @"yyyyMMdd";NSDate *date = [NSDate date];dateFormatter.dateFormat = @"EEEE";Nsstring *dayString = [[dateFormatter stringFromDate:date] cAPItalizedString];NSLog(@"Day: %@",dayString);if ([dayString isEqualToString:@"Monday"]) {}else if ([dayString isEqualToString:@"Tuesday"]) {}else if ([dayString isEqualToString:@"Wednesday"]) {}else if ([dayString isEqualToString:@"Thursday"]) {}else if ([dayString isEqualToString:@"FrIDay"]) {}else if ([dayString isEqualToString:@"Saturday"]) {}else if ([dayString isEqualToString:@"Sunday"]) {}解决方法 您可以使用以下程序.
NSDateComponents *component = [[NSCalendar currentCalendar] components:NSCalendarUnitWeekday fromDate:[NSDate date]];switch ([component weekday]) { case 1: //Sunday break; case 2: //Monday break; ... case 7: //Saturday break; default: break;}总结
以上是内存溢出为你收集整理的ios – 检查NSDate是星期一还是星期二/等全部内容,希望文章能够帮你解决ios – 检查NSDate是星期一还是星期二/等所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)