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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:55:30+00:00 2026-06-04T08:55:30+00:00

I’d like to create a simple pills reminder iOS application (let’s leave notifications aside

  • 0

I’d like to create a simple pills reminder iOS application (let’s leave notifications aside for the moment).
I want to create a single DB record for a pill that has repetitions and check if a specific day intersects date “generated” by the repetition.

Example:
I set a pills period that starts from April 12 and ends April 20, with repetition every 2 days , at 3.00 pm.
So this pills is valid for this dates :

  • April 12 at 3.00pm
  • April 14 at 3.00pm
  • April 16 at 3.00pm
  • April 18 at 3.00pm
  • April 20 at 3.00pm

Questions:

  • Which type of data can describe the information “Every 2 days”? NSDateInterval would be a good solution ?

  • How can i verify that a specific day agrees with my repetition scheme ? (i.e. Check if April 13 is a valid date for the previous example and get “NO” as answer)

  • 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-04T08:55:31+00:00Added an answer on June 4, 2026 at 8:55 am

    Here is an example class which should meet your criteria:

    main.m

    #import <Foundation/Foundation.h>
    #import "DateChecker.h"
    
    int main(int argc, const char * argv[])
    {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    
        // Specify a period in days
        NSInteger period = 2;
    
        // Set the start/end/current days.  These can be retrieved from a database or elsewhere
        NSDate *startDate = [NSDate dateWithString:@"2012-04-12 00:00:00 +0000"];
        NSDate *endDate = [NSDate dateWithString:@"2012-04-20 00:00:00 +0000"];
        NSDate *currentDate = [NSDate dateWithString:@"2012-04-14 00:00:00 +0000"];
    
        // Actually do the checking.  This could alternatively be offloaded to a function in DateChecker
        if([DateChecker date:currentDate isBetweenDate:startDate andDate:endDate])
        {
            if([DateChecker date:currentDate fallsOnStartDate:startDate withInterval:period])
            {
                NSLog(@"The date %@ falls in the specified date period & is on the interval date.", currentDate);
            }
            else
            {
                NSLog(@"The date %@ falls in the specified date period & is NOT on the interval date.", currentDate);
            }
        }
        else
        {
            NSLog(@"The date %@ does not fall in the specified date period.", currentDate);
        }
    
        [pool release];
    
        return 0;
    }
    

    DateChecker.h

    #import <Foundation/Foundation.h>
    
    @interface DateChecker : NSObject
    {
    }
    + (BOOL)date:(NSDate*)date fallsOnStartDate:(NSDate*)beginDate withInterval:(NSInteger)daysInterval;
    + (BOOL)date:(NSDate*)date isBetweenDate:(NSDate*)beginDate andDate:(NSDate*)endDate;
    
    @end
    

    DateChecker.m

    #import "DateChecker.h"
    
    @implementation DateChecker
    
    + (BOOL)date:(NSDate*)date fallsOnStartDate:(NSDate*)beginDate withInterval:(NSInteger)daysInterval
    {
        NSDateComponents *components;
        NSInteger days;
    
        // Get the number of days since the start date
        components = [[NSCalendar currentCalendar] components: NSDayCalendarUnit fromDate: beginDate toDate: date options: 0];
        days = [components day];
    
        // If the number of days passed falls on the interval, then retrun YES
        if(days % daysInterval == 0)
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
    
    + (BOOL)date:(NSDate*)date isBetweenDate:(NSDate*)beginDate andDate:(NSDate*)endDate
    {
        if ([date compare:beginDate] == NSOrderedAscending)
            return NO;
    
        if ([date compare:endDate] == NSOrderedDescending) 
            return NO;
    
        return YES;
    }
    
    @end
    

    That should give you an idea on how to write a class that can handle your requirements. I ran this as a command line app and it seemed to work alright. The function

    + (BOOL)date:(NSDate*)date isBetweenDate:(NSDate*)beginDate andDate:(NSDate*)endDate
    

    was graciously obtained from How to Check if an NSDate occurs between two other NSDates.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words

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.