문제

다음 코드 :

NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"MM/dd"];
NSDate *newTime = [dateFormatter dateFromString:@"10/01"];

결과 날짜를 1970 년 10 월 1 일로 설정합니다. Formatter가 현재 연도의 날짜를 의미한다고 가정하거나 현재 날짜에 가장 가까운 "올바른"방법이 있습니까?

도움이 되었습니까?

해결책

시도해 보았 니 [dateFormatter setLenient:YES]?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top