我在仪器中运行时间分析器。我已经尽可能地简化了代码,以将所有内容归结为确切的问题。循环内具有 checkInString =[_formatter stringFromDate:[checkInArrayCopy objectAtIndex:i]]; 的代码行 占用了 90% 以上的处理时间。关于如何优化此代码的任何想法?
NSDateFormatter *format = [[NSDateFormatter alloc]init];
[format setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
[format setDateFormat:@"MM/dd/YYYY"];
NSString *checkInString;
for (int x=0; x<100; x++) {
for (int i=0; i<checkInArray.count; i++) { //CheckInArray is a NSMutableArray of NSDates, with about 100 objects inside
checkInString =[_formatter stringFromDate:[checkInArray objectAtIndex:i]]; //**90% of processing time
}
}