Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8831989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:25:50+00:00 2026-06-14T08:25:50+00:00

I have an array of non-sequential dates in an NSArray in NSDate format. I

  • 0

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:25:51+00:00Added an answer on June 14, 2026 at 8:25 am

    What about using fast enumeration?

    for (NSDate* dateAsDate in datesAsDates) {
         //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];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Non repeating random number array I have a String array with many
Is there a way to make a non-resizeable vector/array of non-reassignable but mutable members?
So to start, I have an array of XML files. These files need to
I have two sequential (non-associative) arrays whose values I want to combine into a
I have the following code. Basically I want to initialize a std::array of non-POD
I have a 3d array containing the non-cubic bounding box of a sparse geometry.
I have an array of values which are either all-letters or all-numbers and need
I have an array of strings, and need to grab substrings (the strings in
I have an array returned from a web service containing byte values (non binary
I have a array called $A which contains only non zero positive numbers. Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.