我正在尝试在 iPhone 中获取周数。我正在使用这段代码
NSNumber* getWeek() {
NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"w.ee"];
NSString *dateString = [dateFormatter stringFromDate:currDate];
NSNumberFormatter *weekNumber = [[NSNumberFormatter alloc] init];
[weekNumber setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber *week = [weekNumber numberFromString:dateString];
[weekNumber release];
return week;
}
但是,我有不同的结果,在模拟器上还可以,但是当我在 iPhone 上运行时,这让我得到了“0”IOS 5.0.1
有什么帮助吗?