I have an array of non-sequential dates in an NSArray in NSDate format. I need the same set of dates in an array but in NSString formatted as dd/MM. I think I need to loop through reading each date out of the original array converting it to a string and formatting it as I need it, but I can’t figure out how to step through the original array.
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];
}
This answer is close to what I need except it doesn’t read in from and existing array: How to use NSDate formatter with an array of dates?
Please help! Many thanks in advance…
What about using fast enumeration?