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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:00:42+00:00 2026-05-31T20:00:42+00:00

An app allows a user to define an arbitrary set of days like so:

  • 0

An app allows a user to define an arbitrary set of days like so:

  • Day 1 – Pick flowers
  • Day 2 – Have coffee
  • Day 3 – Go swimming

This set of days may have only one entry or it may have many. Suppose that this cycle of days begins on March 23, 2010.

Is there a general algorithm that can determine which day in a cycle corresponds to a given calendar day?

On March 24th, the algorithm should return Day 2, March 25th should be Day 3, March 26th should be Day 1, and so on…

More specifically, I am writing this code for a Cocoa application. So, barring the existence of a more general technique can the Calendar classes help me?

  • 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-31T20:00:44+00:00Added an answer on May 31, 2026 at 8:00 pm
    NSCalendar *gregorian = ...;
    NSDate *startDate = ...;
    NSDate *currentDate = [NSDate date];
    NSUInteger unitFlags = NSDayCalendarUnit;
    NSDateComponents *components = [gregorian components:unitFlags fromDate:startDate  toDate:currentDate options:0];
    NSInteger days = [components day];
    

    days now contains the number of days which have elapsed since the start date. This can be used as an index (zero-based) into your array of activities. You can use the modulus operator with the length of the cycle as the dividend to compute indices after the first transit around the cycle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a flex app which allows user to create some content. this content
I have an app that allows the user to choose an image, at design
I'm making a Django web-app which allows a user to build up a set
I have an app that allows the user to choose a picture from their
I'm currently working on a reasonably simple MVC app which allows the user to
I'd like to allow user to change the setting of app. But I am
I have a controller action that allows a user to download a file with
I have a MKMapView and in the Map View Show User Location is set.
I have an audio recording app in Windows Phone 7. The app allows a
I have a problem to define the required permission an user should allow to

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.