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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:08:13+00:00 2026-06-17T03:08:13+00:00

I cannot use a UIDatePicker. I just want to throw that out at the

  • 0

I cannot use a UIDatePicker. I just want to throw that out at the very beginning before all the commenters tell me to just use a UIDatePicker. I want to have a Picker Wheel that shows all the day of the year, leading up to today, and display it as Day: 1/Jan 1, Day: 2/Jan 2 and so on. Here is what I have so far, which detects what day ‘number’ of the year it is, and populates the PickerWheel with all the dates leading up to today:

NSCalendar *currentCalendar = [NSCalendar currentCalendar];
    NSDate *today = [NSDate date];

    NSInteger dc = [currentCalendar  ordinalityOfUnit:NSDayCalendarUnit
                                               inUnit:NSYearCalendarUnit
                                              forDate:today];
    options = [[NSMutableArray alloc]init];

    for (int index = 1; index <= dc; index++)
    {
        NSString *pickerItemTitle = [NSString stringWithFormat: @"Day: %d", index];
        [options addObject: pickerItemTitle];
    }

What can I do to make it also match up the NSInteger with the date, and have that be part of the pickerItemTitle as well?

  • 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-17T03:08:14+00:00Added an answer on June 17, 2026 at 3:08 am

    Got it figured out. Added some code to form a date based off integer of day into the loop. Now, the viewWillAppear method that sets the array for the uipickerview looks like this:

    - (void)viewWillAppear:(BOOL)animated
    {
    
        NSCalendar *currentCalendar = [NSCalendar currentCalendar];
        NSDate *today = [NSDate date];
    
        NSInteger dc = [currentCalendar  ordinalityOfUnit:NSDayCalendarUnit
                                                   inUnit:NSYearCalendarUnit
                                                  forDate:today];
        options = [[NSMutableArray alloc]init];
    
        for (int index = 1; index <= dc; index++)
        {
            NSDateComponents *components = [[NSDateComponents alloc] init];
            [components setDay:index];
            NSCalendar *gregorian = [[NSCalendar alloc]
                                     initWithCalendarIdentifier:NSGregorianCalendar];
            NSDate *date = [gregorian dateFromComponents:components];
            NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
            [formatter setDateFormat:@"MMM dd"];
            NSString *articleDateString = [formatter stringFromDate:date];
            NSString *pickerItemTitle = [NSString stringWithFormat: @"Day: %d/%@", index, articleDateString];
            [options addObject: pickerItemTitle];
        }
        [super viewWillAppear:YES];  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We cannot use NSFetchRequest without providing NSSortDescriptor(s). All i want to do is fetch
I cannot use threads thus I want to write a server program that can
What is the reason that you cannot use zero at the beginning of a
KSH HP-SOL-Lin Cannot use xAWK I have several strings that are quite long and
I read that one cannot use ASP.NET MVC with Server Control which have ViewState
I cannot use third party software/libraries and have a zip file that I have
I have now admitted defeat that you cannot use/build a good audio pitch function
Why cannot use body::selection , when i want anything that can highlight to be
I cannot use AsEnumerable() on DataTable, I'm using C# 3 but I'm just targeting
I see that we cannot use if not exists in the create virtual table

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.