2010-12-13 12 views
5
NSDate *future = [NSDate dateWithString:@"2010-12-25 00:00:00 -0600"]; 

내가 경고 메시지를 받고 있어요 + dateWithString에 응답하지 않을 수 있습니다 NSDate+dateWithString'있는 NSDate'

어떤 아이디어가 응답하지 않을 수 있습니다?

답변

12

어쩌면 당신은 NSDateFormatter에있는 방법을 의미할까요?

+6

알겠습니다. NSString * dateString = @ "25-Dec-10"; \t \t NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; \t dateFormatter.dateFormat = @ "dd-MMM-yy"; \t \t NSDate * future = [dateFormatter dateFromString : dateString]; –

22

NSDate dateFromString은 Mac OS (iOS 제외)입니다.

+1

이것을 어떻게 아십니까? 내가보고있는 문서는 iOS, OSX 만 언급하지 않습니다. https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html#//apple_ref/occ/clm/NSDate/dateWithString : – ericsoco

+1

@ericsoco, 시도해보십시오. [NSDate class ref for iOS] (http://developer.apple.com/library/ios/#documentation/cocoa/reference/foundation/Classes/NSDate_Class/Reference/Reference.html). – JohnK

+0

url을 열지 않아도 iOS 용 문서가 아닌 것을 알 수 있습니다. 그리고 내부를 들여다 보면 ... "사용 가능 : OS X v10.0 이상에서 사용 가능" –