3

I am developing a Today's Extension of an app. I am having some problems regarding App Groups that are used as shared containers between extension and containing app.

  1. Where is the App Group data stored?

  2. How to see what data is stored in the App Group?

PGDev
  • 23,751
  • 6
  • 34
  • 88

1 Answers1

1

Shared Containers is simply a UserDefault dictionary that is shared between Extensions in an App. To store data in the container Init your container using the suiteName UserDefault:

let SharedDefaults = UserDefaults.init(suiteName: "group.com.YOURGROUP")!

TheN to set a value, in this case a String:

SharedDefaults.set("something", forKey: "aKey")

And to retrieve the information (from either the Extension or App) use:

let myString = SharedDefaults.string(forKey: "aKey")

This explains how to to print the contents of the UserDefaults: Easy way to see saved NSUserDefaults?

Community
  • 1
  • 1
svarrall
  • 8,545
  • 2
  • 27
  • 32
  • I know how to use App Group. Please read the question carefully. I want to know where in the system App Group data is stored? – PGDev Dec 31 '16 at 16:32