Action Extension AND Sharing Core Data

前端 未结 1 878
星月不相逢
星月不相逢 2021-01-25 00:06

I am using the Action extension in my Application.

Our app currently uses Core Data. I am sharing this between the app and the Action Extension using App Groups and suc

相关标签:
1条回答
  • 2021-01-25 00:21

    The problem you describe happens because there's no notification to tell your app that there's new data in the persistent store file, so it just keeps showing the existing data. You need to handle this yourself.

    A simple approach is to observe UIApplicationDidBecomeActiveNotification in your app. Any time you receive that, reload your data. You'll get any new entries created by the extension.

    A more sophisticated approach is to use something like MMWormhole to notify the app of new content. Then it would only load new entries when they actually exist, instead of reloading every time it becomes active.

    0 讨论(0)
提交回复
热议问题