我在NSDray格式的NSArray中有一個非連續日期數組。我需要在數組中使用同一組日期,但在NSString中格式化爲dd/MM。我想我需要通過從原始數組中讀取每個日期進行循環,將其轉換爲字符串並根據需要對其進行格式化,但我無法弄清楚如何逐句通過原始數組。將NSArray的NSArray轉換爲格式化日期數組作爲字符串
NSError *error2;
NSArray *swim750mArray = [context executeFetchRequest:request2 error:&error2];
if (swim750mArray == nil) {
NSLog(@"The fetch request2 returned an array == nil");
} else {
NSLog(@"The fetch request2 returned an array...");
NSLog(@"%@", swim750mArray);
NSArray *datesAsDates = [swim750mArray valueForKey:@"date"];
NSMutableArray* arrayOfDatesAsStrings = [NSMutableArray arrayWithCapacity:count];
//SomeCode - Convert the Array of NSDates to a new Array of dates as NSStrings...
for (int i=0; i<index; i++) {
//get the date next NSDate from the array as: NSDate *dateAsDate...
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM"];
NSString *dateAsStr = [dateFormat stringFromDate:dateAsDate];
[arrayOfDatesAsStrings addObject:dateAsStr];
}
這個答案是接近我需要的只是它不從和現有陣列讀什麼:How to use NSDate formatter with an array of dates?
請幫幫忙!非常感謝提前...