I am building two related iOS apps, say com.foo.bar and com.foo.baz, and I would like to save data (all but one piece is an NSString; the one exception is an NSArray of NSStrings) so that com.foo.bar, com.foo.baz, and (intended future expansion) additional com.foo.* apps would work in the same way.

How can I save and restore NSString / NSArray of NSString values so that the whole family will see it?

有帮助吗?

解决方案

There are a couple of ways your apps can share data. The easiest is probably iCloud. All apps will have to have the same Ubiquity Container.

From the iCloud docs:

Configuring a Common Ubiquity Container for Multiple Apps
In the Xcode target editor’s Summary tab, you can request access to as many ubiquity containers as you need for your app. For example, say you provide a free and paid version of your app. You’d want users, who upgrade, to retain access to their iCloud documents. Or, perhaps you provide two apps that interoperate and need access to each other’s files. In both of these examples, you obtain the needed access by specifying a common ubiquity container and then requesting access to it from each app.

The other way (I think) is to use the Keychain data to share between apps. I'm not sure how that works.

其他提示

Unfortunately it's not allowed to write a data on file system that will be shared between apps.

Use iCloud to share data between 2 apps or implement your own server to keep shared data.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top