<分区>
Possible Duplicate:
How do I get the day of the week in Objective-C?
我有一个连接到 nsstring 的 uilabel。但是,我试图将 nsstring 设置为星期几(星期一、星期二等)。每次我运行它时,它什么也没给我。我有一种感觉,这是因为我没有从我的 nsdate 中获得值(value)。但是,我是 xcode 的新手,所以我真的不知道我做错了什么。
-(void)viewDidLoad {
NSDate *today = [[NSDate alloc] init];
NSCalendar *gregorian = [[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar];
// Get the weekday component of the current date
NSDateComponents *weekdayComponents = [gregorian components:NSWeekdayCalendarUnit
fromDate:today];
NSString *dateString = weekdayComponents;
_label.text = dateString;
}