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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:42:40+00:00 2026-05-25T15:42:40+00:00

I have one iphone application in which recurring events happens.the duration are like every

  • 0

I have one iphone application in which recurring events happens.the duration are like every day,every 2nd day,every 3rd day..,every week on mon,every week on tues,…,every second week on mon,..,every month on 1sr,every month on 2nd…,every second month on 1st,every second month on 2nd,… For some events there is end date but some events occurs forever.so how can i insert them automatically in sqlite3 database.eg.If an event repeats every 3rd day.how can i store it automatically after 3 days.or should i store all the events at the time of creation.If i store all the evnets at time of creation then the events that repeats forever.upto what duration i should store the value of them in database.

For this i have thought 2 approaches.one is storing just one occurance with repeated duration like every day.but in my application edit and delete functionality is also there.suppose event has one field event description then it can be different for different dates if user edit the events.events are displayed datewise on screen for a particular month and user can navigate to any previous and next month for current ,next and previous years.So if i use only single occurance then where should those edited or deleted events should be stored.
And if i take second approach store each occurance in database.Then upto what duration i should store the events which has no enddate.or is there a way that insert is automatically performed after specified duration.

  • 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-25T15:42:41+00:00Added an answer on May 25, 2026 at 3:42 pm

    Two ways, one an easy hack, one more difficult but correct 🙂

    (1) Store each individual event for the next 10 years or so (or however long you want to!)

    Good :
    Easy and quick to implement

    Bad :
    Your db will get big very quickly.
    What if the user wants to edit the details – how do you edit all of them at once?
    What if the user wants to cancel / move the event- you have to delete all of them!

    (2) Store some sort of ‘event recurrence’ information in the database with each event i.e. ‘Every tuesday’

    Good :
    Only one event in the database, regardless of how many times it repeats.
    Easy for the user to edit / delete the event – there’s only one row in the database.

    Bad:
    More complicated event object – each event must have a list of ‘when this event happens’ information.
    Makes very complicated event timings hard – i.e. ‘last friday of every month’
    Takes longer to implement


    EDIT : My personal choice

    I would choose option (2) – it takes longer to implement but I think option (1) will et you into trouble in the future.

    I would have a data model like

    Event has many Occurances

    where your Event is the thing that the user has created with a description, start date etc and an Occurance is some sort of object that will say ‘every friday’ or ‘not on the 4th’.

    As part of creating an event, the user will say ‘occurs once on Friday 13th’ or ‘occurs every Wednesday’. That information is used to create an array of Occurance objects.

    Occurance would be a protocol that simply has the method occursOn: so you can have lots of different types of occurance (and you can add new types as your app gets more complicated).

    The Event object would have a method something like occursOn: where you give it an NSDate and it returns if it occurs on that day. It does this by asking each of it’s occurances in turn to see if they apply to that day.

    To deal with deleted events, just add an Occurance to the end of the Event’s array that overrides the others – i.e. ‘not on Friday 13th’.

    For example :

    (1)

    A user creates an event called ‘My Event’ starting on 1st Jan, occurring every Friday.

    Your app would store

    Event
        description : 'My Event',
        start date : 1st Jan 2011
        occurances :
            WeeklyOccurance
                day : Friday
    

    where WeeklyOccurance implements the <Occurance> protocol

    (2)

    The user asks to show the week’s events, starting on Sunday the 8th Jan 2011

    The app would :

    For each day in the week
        For each event in the database
            if occursOn: this day
                show the event on the ui
    

    and for our event ‘My Event’, it would implement occursOn: like

    - (BOOL)occursOn:(NSDate *)date
    
        is this date before this event starts
            if it is, return NO
    
        set remembered = NO
        for each occurance
           does this occurance say 'yes','no' or '?' for this date?
    
           if 'yes' set remembered YES
           if 'no' return NO
    
           if '?' continue the loop
    
       return remembered
    

    Because WeeklyOccurace only knows that it occurs on Fridays, it would return ‘yes’ for Fridays and ‘?’ for all other days so the ui would show ‘My Event’ on Friday and not on any other days.

    To add different types of occurance, just implement the <Occurance> protocol in different ways.

    (3)

    The user says actually it should be on every Friday apart from the 22nd

    The app would create another Occurance, this time a NotOnThisDayOccurance and add it to the end of the Event’s array i.e.

    Event
        description : 'My Event',
        start date : 1st Jan 2011
        occurances :
            WeeklyOccurance
                day : Friday
            NotOnThisDayOccurance
                day: 22nd Jan 2011
    

    Now, if the users asks to display the weekly events, ‘My Event’ would look do this :

    Ask the WeeklyOccurance if it's valid for friday the 22nd - this would return yes.
    Ask the NotOnThisDayOccurance if it's valid for friday the 22nd - this would override the previous result and say NO
    

    Therefore, the event would not show up on the 22nd but would show up on all the other fridays.

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

Sidebar

Related Questions

I have developed one application in iPhone which contains videos. Now I want to
I have an iPhone application with Tabbar. One of the tabs is UIWebView which
i have one application in iphone in which i have to show notification when
I have one iphone application in which i am adding uitableview inside uitableviewcell.in that
Is it possible to have more than one application running on the iphone accessing
I have a custom iPhone application which doesn't rely on UIKit in any way
I have upgraded my iPhone SDK from 3.1.2 to 4. The application which I
I have kind of Listing application for iPhone application, which always calling a web
I have a UITableView in an iPhone application which I am refreshing (by calling
I am developing an iphone application in which i have to return keyboard as

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.