【发布时间】:2010-05-19 02:24:50
【问题描述】:
//NSString *compileDate = [NSString stringWithFormat:@"%s", __DATE__];
NSString *compileDate = [NSString stringWithUTF8String:__DATE__];
NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setDateFormat:@"MMM d yyyy"];
//[df setDateFormat:@"MMM dd yyyy"];
NSDate *aDate = [df dateFromString:compileDate];
好吧,我放弃了。为什么 aDate 有时会返回 nil?
我是否使用注释掉的行...或它们匹配的替换行是否重要?
【问题讨论】:
-
不值得回答的小提示:由于预处理器的工作方式,要将 DATE 作为 NSString,您可以简单地编写 @__DATE__
标签: iphone date compilation nsdate nsdateformatter