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

  • Home
  • SEARCH
  • 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 6374205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:27:33+00:00 2026-05-25T01:27:33+00:00

I have an NSArray filled with about 30 dates in the NSDate format, What

  • 0

I have an NSArray filled with about 30 dates in the NSDate format,

What I need to do is create another array from this, which contains a boolean for all of the dates from the first date to the last date.

ex Array 1
1/1/11
3/1/11
5/1/11

Array 2
Yes
No
Yes
No
Yes

I need this for tapku library calendar

This is what I have so far but the i never changes

int i=0;
for (NSDate *date = [[startingDate copy] autorelease]; [date compare: endingDate] < 0;
     date = [date dateByAddingTimeInterval:24 * 60 * 60] ) {
    NSLog( @"%@ in [%@,%@]", date, startingDate, endingDate );

    int day1 = [[NSCalendar currentCalendar] ordinalityOfUnit:NSDayCalendarUnit inUnit:NSEraCalendarUnit forDate:[eventDates objectAtIndex:i]];
    int day2 = [[NSCalendar currentCalendar] ordinalityOfUnit:NSDayCalendarUnit inUnit:NSEraCalendarUnit forDate:date];

    if(day1-day2==0) {
        NSLog(@"yeh");
        i=i+1;
        //add yes to array2

    } else {
        NSLog(@"nah");
        NSLog(@"%i",i);
        //add no to array 2
    }
}
  • 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-25T01:27:33+00:00Added an answer on May 25, 2026 at 1:27 am

    I don’t think I quite understand what you want to do, but I’ll give it a try.

    Suppose you have 2 NSDate‘s, call them date1 and date2, and you want to mark any entries in an array of NSDate‘s, call it arrayOfDates, that are between the 2 NSDate‘s, or not, and store the YES or NO values in another array, call it boolValuesOfDates. Then try this method:

    - (void)compareDatesOfArrayFromDate:(NSDate *)date1 toDate:(NSDate *)date2; {
    
      NSDate * firstDate;
      NSDate * secondDate;
    
      if([date1 timeIntervalSinceDate:date2] >= 0){
        firstDate = date2;
        secondDate = date1;
      }
      else{
        firstDate = date1;
        secondDate = date2;
      }
    
      if(boolValuesOfDates != nil)
        [boolValuesOfDates release]; // Release the YES/NO array for the new values.
    
      boolValuesOfDates = [[NSMutableArray alloc] initWithCapacity:[arrayOfDates count]];
    
      BOOL isInbetweenDates;
      NSDate * curDate;
    
      for(int i = 0; i < [arrayOfDates count]; i++){
        curDate = [arrayOfDates objectAtIndex:i];
        isInbetweenDates = NO;
        if([curDate timeIntervalSinceDate:firstDate] >= 0){
          if([curDate timeIntervalSinceDate:secondDate] <= 0){
            isInbetweenDates = YES;
          }
        }
        [boolValuesOfDates addObject:[NSNumber numberWithBool:isInbetweenDates]];
      }
    }
    

    This method checks the order of the 2 entered NSDate‘s, and then compares the NSDate‘s in the array, and if they are in between, marks them with a YES, or NO otherwise. Hope that Helps!

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

Sidebar

Related Questions

I have an NSArray which contains Person objects. This person object contains the following;
I have an NSArray of keys from an NSDictionary like this: NSArray *array =
I have an NSArray filled with bools (expressed as a number), and I need
I have an NSArray which contains NSDictionary objects with keys that are NSNumber objects.
I have an NSArray that contains date strings (i.e. NSString) like this: Thu, 21
I have NSArray that contains NSDictionaries. I need to convert it to CFMutableArray that
I have an NSArray and in the first position in this array there is
I'm getting an NSArray filled with something from a helper class. I have a
I have an NSArray and I'd like to create a new NSArray with objects
I have an NSArray of NSDictionary objects which I would like to be able

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.