简体   繁体   中英

iOS Today Extension - Share core data between

I have an app which uses core data and i'm trying to add a today extension to it which also access the data I have it set up so far and its able to access the data, but i'm having trouble with the classes for the entities. I get the following error

CoreData: warning: Unable to load class named 'Med_Track_2.Medicine' for entity 'Medicine'

Med_Track_2 is the product name for the main app, Medicine_Tracker_2 is the name for the extension The medicine class is added to both targets

Is there a way around this?

You have to share the resources between your app and your extension. Read the "Sharing Data with Your Containing App" chapter: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1

Also you have to add the files you want to use to the Extension's target too. (Edit the Build phases / Compile Sources sections of the extension's target)

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