问题
I would like to access my Realm from an iOS extension however the realm path is unavailable when using the Realm Mobile Platform. I've received advice from realm to hold a cloned copy and keep it in sync. How can that be achieved? ...and is it considered a "clean" solution? (there could be multiple realms)
回答1:
You should just open the synced Realm from your extension by creating a Realm configuration with a proper sync configuration (specifying user and remote Realm URL), like usual.
This is the only currently supported way to use the same synced Realm with both an app and its associated extension(s). The underlying reason is because Realm's synchronization subsystem doesn't support accessing the same synced Realm file concurrently from multiple processes.
来源:https://stackoverflow.com/questions/44786619/accessing-realm-from-an-ios-extension-while-using-realm-mobile-platform