Iphone dateformatter可以在模拟器中工作,但不能在设备上工作

Iphone dateformatter可以在模拟器中工作,但不能在设备上工作,iphone,ios-simulator,device,nsdateformatter,Iphone,Ios Simulator,Device,Nsdateformatter,此代码在模拟器上工作。。。但不是在我的iPodtouch上。。。在ipod上,我看到了未配对的日期:-( //日期之前=2010年6月20日星期日06:00:00+020 [formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss Z"]; NSDate *d = [formatter dateFromString:string]; [formatter setDateFormat:@"dd.MM.yy

此代码在模拟器上工作。。。但不是在我的iPodtouch上。。。在ipod上,我看到了未配对的日期:-(

//日期之前=2010年6月20日星期日06:00:00+020

        [formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss Z"];
        NSDate *d = [formatter dateFromString:string];
        [formatter setDateFormat:@"dd.MM.yyyy HH:mm"];
        string = [NSString stringWithString:[formatter stringFromDate:d]];
        [currentDate appendString:string];

在设备上,需要显式设置区域设置

插入以下行:

[formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
紧接着:

[formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss Z"];
[formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss Z"];