Iphone NSDateFormatter dateFromString:是否应该为无效字符串返回nil?
根据类引用,dateFromString方法返回使用接收方当前设置解释的字符串的日期表示形式。使用以下代码:Iphone NSDateFormatter dateFromString:是否应该为无效字符串返回nil?,iphone,objective-c,cocoa,nsdateformatter,Iphone,Objective C,Cocoa,Nsdateformatter,根据类引用,dateFromString方法返回使用接收方当前设置解释的字符串的日期表示形式。使用以下代码: NSDateFormatter * formatter = [[[NSDateFormatter alloc] init] autorelease]; [formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]]; [formatter setDateFormat:@"MM
NSDateFormatter * formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
[formatter setDateFormat:@"MMddyy"];
NSDate * date = [formatter dateFromString:@"2010-04-27T17:45:44.763"];
在SDK 3.1.3中返回零,但在SDK 3.2中返回2010-01-20 00:00:00-0300。3.2版本的行为是否正确?我认为应该返回nil。使用SDK 4。我认为它应该返回nil。使用SDK 4。我在3.1.3上测试了它,它总是返回nil。3.2的结果真的很奇怪,与错误的字符串没有关系。我在3.1.3上测试了它,它总是返回nil。3.2的结果非常奇怪,与错误的字符串没有关系。