简体   繁体   中英

How to save a key value pair that can be accessed by all apps (globally)

I want to save some alpha-numeric value that needs to be accessed by 2 or more apps.

NSUserDefaults is only for within the same app, so I was wondering if there was something similar which can save key value pairs globally.

Additional info: I'm using my first app to save the UDID or some unique key on my phone, so that Appium can later access it.

You can use Shared User Defaults - iOS8+

As long as all your apps are in the same 'App Group' and use the same 'SuiteName' and keys - they can share info there.

Using it is as simple as using regular UserDefaults - you just need a little more setup.

You can find a good guide here: https://medium.com/ios-os-x-development/shared-user-defaults-in-ios-3f15cd2c9409

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