使用JTAppleCalender和CoreData的习惯跟踪器 [英] Habit tracker with JTAppleCalender and CoreData
问题描述
我正在尝试使用 CoreData
和 JTAppleCalendar
创建一个习惯跟踪器。
我希望用户能够养成一个习惯,然后在设定的日期结束时将其保存为一天。该界面将显示日历,用户可以设置某些日期的习惯。
努力找出如何使用日历来实现该模型以使其正常工作。
我应该如何为 CoreData
构建模型?
这里是实现此目的的一种方法。习惯的名称,开始日期和结束日期。
当用户为习惯创建对象时,为此创建相应的ReminderObjects习惯,将startDate和endDate之间的所有日期作为ReminderObjects的fireDate。
现在在JTAppleCalendarView中显示时
- 过滤要显示的习惯的ReminderObjects
- 当用户从JTAppleCalendarView中选择日期时,从fireDate过滤ReminderObjects。
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
?
Here is one way to implement this.
- Make a model for Habit with attributes like name of the habit, start date and end date.
- Create a model for ReminderObjects with attributes like fireDate, completedStatus etc.
- 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
- Filter the ReminderObjects for the Habit you want to display
- Filter the ReminderObjects from the fireDate when the user selects a date from the JTAppleCalendarView.
这篇关于使用JTAppleCalender和CoreData的习惯跟踪器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!