NSString을 NSDate로 변환하고 다시 NSString 형식으로 변환하는 데 문제가 있습니다. codesnippet 내 아이폰 4NSString to NSDate는 iDevice에서 작동하지 않습니다.
NSString *pubDate = @"Tue, 18 Oct 2011 05:00:00 +0100";
NSDateFormatter *formater1 = [[NSDateFormatter alloc] init];
[formater1 setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss ZZZ"];
NSDate *d = [formater1 dateFromString:pubDate];
NSLog(@"d: %@", d);
NSDateFormatter *formater2 = [[NSDateFormatter alloc] init];
[formater2 setDateFormat:@"dd MMM yyyy"];
NSString *k = [formater2 stringFromDate:d];
NSLog(@"k: %@", k);
[formater1 release];
[formater2 release];
을 시뮬레이터의 출력에 해당하는 경우에는 iOS 시뮬레이터에 문제가 있지만 나던 작업없이 작동하는 것입니다 :
는d: 2011-10-18 04:00:00 +0000
k: 18 Oct 2011
장치의 출력은 다음과 같습니다
d: (null)
k: (null)
제안 사항이 있으십니까?
thx hypercrypt. 내 하루를 만들었 어. – CarlJ