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 6365257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:16:15+00:00 2026-05-25T00:16:15+00:00

I am creating an app that needs to put all dates of the year

  • 0

I am creating an app that needs to put all dates of the year into a uitableview (each date having their own cell). Is there any way to use the nsdate to populate each cell with every date?

  • 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-05-25T00:16:16+00:00Added an answer on May 25, 2026 at 12:16 am

    You will need to create the NSDate instances manually if you need to display all dates from 1 January through 31 December.

    The following methods might help with the NSDate instances you need for your UITableView cells:

    - (NSInteger)daysInYear:(NSInteger)year {
        if (year % 400 == 0)        return 366;
        else if (year % 100 == 0)   return 365;
        else if (year % 4 == 0)     return 366;
        else                        return 365;
    }
    
    
    - (NSDate *)firstDayInYear:(NSInteger)year {
        NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
        [fmt setDateFormat:@"MM/dd/yyyy"];
        NSDate *firstDayInYear = [fmt dateFromString:[NSString stringWithFormat:@"01/01/%d", year]];
        [fmt release];
        return firstDayInYear;
    }
    
    
    - (NSDate *)dateWithDayInterval:(NSInteger)dayInterval sinceDate:(NSDate *)referenceDate {
        static NSInteger SECONDS_PER_DAY = 60 * 60 * 24;
        return [NSDate dateWithTimeInterval:dayInterval * SECONDS_PER_DAY sinceDate:referenceDate];
    }
    

    In your tableView:cellForRowAtIndexPath: method you can then instantiate the corresponding NSDate instance:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        NSDate *dateForCell = [self dateWithDayInterval:indexPath.row sinceDate:self.firstDayInYear];
        // ... rest of your method ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a WPF app that needs to allow users to work in
I'm creating an app that should list the date and time when a button
I'm creating and app that will rely on a database, and I have all
I am creating an app that is having a UIWebView which contains an advert.
I'm creating an application that I want to put into the cloud. This application
I'm creating an app where user needs to login first and only after that
I'm working on an application that needs to temporarily put a machine into a
I'm creating a WP7 app that needs to continue running when the user is
We are creating an app that uses modules which are dynamically loaded into the
I am creating an app that will point a simple arrow in the direction

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.