Habit tracker with JTAppleCalender and CoreData

302 Views Asked by At

I’m trying to create a habit tracker using CoreData and JTAppleCalendar.

I want the user to be able to create a habit and then when completed on a set date it saves it for the day. The interface would show a calendar which the user can set habits for certain dates.

Struggling to work out how to implement the model with the calendar to get this working.

How should I construct the model for CoreData?

1

There are 1 best solutions below

3
On BEST ANSWER

Here is one way to implement this.

  1. Make a model for Habit with attributes like name of the habit, start date and end date.
  2. Create a model for ReminderObjects with attributes like fireDate, completedStatus etc.
  3. Now create a relationship from Habit to ReminderObjects as one-to-many.

When the user creates an object for Habit, create the corresponding ReminderObjects, for that Habit, for all the dates between startDate and endDate as the fireDate of the ReminderObjects.

Now when displaying in the JTAppleCalendarView

  1. Filter the ReminderObjects for the Habit you want to display
  2. Filter the ReminderObjects from the fireDate when the user selects a date from the JTAppleCalendarView.