使用JTAppleCalender和CoreData的习惯跟踪器 [英] Habit tracker with JTAppleCalender and CoreData

查看:91
本文介绍了使用JTAppleCalender和CoreData的习惯跟踪器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 CoreData JTAppleCalendar 创建一个习惯跟踪器。



我希望用户能够养成一个习惯,然后在设定的日期结束时将其保存为一天。该界面将显示日历,用户可以设置某些日期的习惯。



努力找出如何使用日历来实现该模型以使其正常工作。



我应该如何为 CoreData 构建模型?

解决方案

这里是实现此目的的一种方法。习惯的名称,开始日期和结束日期。

  • 为具有RemoderObjects属性的模型创建一个属性,例如fireDate,completedStatus等。

  • 现在创建关系从习惯到一对多的ReminderObjects。

  • 当用户为习惯创建对象时,为此创建相应的ReminderObjects习惯,将startDate和endDate之间的所有日期作为ReminderObjects的fireDate。



    现在在JTAppleCalendarView中显示时


    1. 过滤要显示的习惯的ReminderObjects

    2. 当用户从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.

    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.

    这篇关于使用JTAppleCalender和CoreData的习惯跟踪器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆