以下目标-C代码6.2(SDK 8.2):
NSArray *the_datums = [[readCSV alloc] read_csv_from_url:fname] ;// is an array of date in Y-M-D H format read from a CSV file
NSMutableArray *les_dates = [[NSMutableArray alloc] init];
for (int i =0 ; i< the_datums.count ; i++){
NSString *str = [the_datums objectAtIndex:i] ;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd H"];
NSDate *date = [dateFormatter dateFromString: str];
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"d"];
NSString *convertedString = [dateFormatter stringFromDate:date];
[les_dates insertObject:convertedString atIndex:i];
}
如果Iphone / Ipad不在AM:PM模式(通过IOS控制面板),则有效。但是,如果我将提示切换到AM:PM并重新启动APP,Xcode会把我的石头扔给我:
*由于未捕获的异常终止应用&#39; NSInvalidArgumentException&#39;,原因:&#39; * - [__ NSArrayM insertObject:atIndex:]:对象不能为零&#39; < / p>
当用户更改iphone时钟的格式时,NSdateFormatter结果如何变化并且为零?有没有解释?