What's the best way to show recurring events in uitableview

Deadly 提交于 2019-12-13 05:54:15

问题


I'm developing a Calendar app on iOS and showing all events in a UITableview with NSFetchedResultsController.

Due to some reasons, I can't use EKEvent as event model, so I decide to implement a new Event model. When perform recurring events, there are two ways:

  • For each recurring event, generate all sub-events according to recurring rules, and insert them to core data.

    • Positive: I can use NSFetchedResultsController to show all events in UITableview normally.
    • Negative: For any updates to a recurring event, I have to update all sub-events generated by this event.
  • For each recurring event, just generate all sub-events in ViewDidLoad, no database communication.

    • Positive: I only need to update one event object.
    • Negative: I can't use NSFetchedResultsController

I just don't like both of them, what's the best way to solve this problem?


回答1:


Dealing with recurring content is problematic, especially when you don't strictly own the underlying data (because it's in the device calendar). So, try taking the best parts from each of your proposed solutions and dropping the bits you don't like:

  1. Use an FRC with a single event
  2. When the FRC gives you updates, calculate all of the recurring events
  3. Display from your calculated events, not directly from the FRC

In this way you're using the FRC to get the 'underlying' data and to trigger updates when things change in the data store, but you're also able to deal with the multiplicity cleanly.



来源:https://stackoverflow.com/questions/32562394/whats-the-best-way-to-show-recurring-events-in-uitableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!