I have a SQLite database storing all of my calendar events, modeled like so:
TimerEvent
*Attributes
-date
-dateForMark
-reminder
*Relationships
-eventInfo (<->)
EventInfo
*Attributes
-location
-notes
-recurringKey
-reminderKey
-title
*Relationships
-timerEvent (<->)
-repeat (<->>)
Repeat
*Attributes
-repeatDate
*Relationships
-eventInfo(<->>)
When you create an event, a TimerEvent is created, and the three date values are plugged in. Then, a relationship to an EventInfo entity is created, with the event’s location, title, notes, and reminder/recurring keys plugged in. If the recurring key is not -1, a Repeat entity is created based on the number of repeat dates that fall between the TimerEvent date and a date determined from user input.
My calendar than reads all of the dates, displays them, and then in my AgendaView can display all of the information from the “parent” entity (EventInfo is NOT a parent entity of Repeat. It just has a one-to-many relationship with the many repeats that could be created). An issue arises when editing… If I wanted to edit one of the repeat events, only that event (not the one’s following, or the one’s before), and i traced the Repeat object back up to the EventInfo object, changing that info would change the info for every event. I can only imagine two solutions to this:
1. Add extra NSString attributes to repeat events for when events are edited
2. Create a new event JUST for that object, nullify the existing relationship,
and use the repeatDate as the main date.
Solved by creating an individual
TimerEventwith it’s ownEventInfofor each repeat event, added arepeatIDattribute to theTimerEvent‘s, added a search forrepeatID‘s in order to get all of those associated to the current event. The ID’s are generated from a newNSUserDefaultkey that assigns and increments every time a new repeating event is created.