我正在尝试使用下面的代码和变量 NSString 来获取星期几。我在工作日使用的任何值总是返回为 2。我做错了什么?
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"EEE, dd MMM yyyy"];
NSString *stringDate = @"23/05/2013";
NSDate *dateStr = [dateFormatter dateFromString:stringDate ];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *weekdayComponents =[gregorian components:NSWeekdayCalendarUnit fromDate:dateStr];
gWeekday = [weekdayComponents weekday];