简体   繁体   中英

What is the most memory efficient way to refresh table with data, iOS, Swift 3?

What is the most memory/battery-efficient approach for an app that shows table view with meetings? Meetings can be eventually updated any moment from third party side (there is no way to be notified about it, it just fetches meetings from iOS native calendar):

  1. Refresh screen every minute (thus re-building the same amount of cells that are present on the screen, 5-6 cells at most).

  2. Fetch meetings in the background, and compare the objects with equatable protocol (object Meeting has references to other objects, that have in turn their own objects, and every level needs to be compared to be sure two objects are equal), and only IF the object has changed, reload table with data?

Have you looked into Observing External Changes to the Calendar Database? From Apple's docs:

An EKEventStore object posts an EKEventStoreChangedNotification notification whenever it detects changes to the Calendar database. Register for this notification if your app handles event or reminder data.

That's where I would start --- gotta be a much better way to go about it than to "refresh" every minute...

ref: https://developer.apple.com/library/content/documentation/DataManagement/Conceptual/EventKitProgGuide/ObservingChanges/ObservingChanges.html#//apple_ref/doc/uid/TP40009765-CH4-SW1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM