NSUserDefaults with suit name swift

940 views Asked by At

I have created a custom keyboard for ios using swift and i need to add a settings page so i have try to pass data between container application and keyboard application i have added the AppGroups in AppGroup and this is the code i have used

in container app view controller

var defaults: NSUserDefaults = NSUserDefaults(suiteName: "group.xxxxx")! defaults.setObject("t1", forKey: "theme")

and in UIInputViewController class

var defaults: NSUserDefaults = NSUserDefaults(suiteName: "group.xxxxx")! var test = defaults.stringForKey("theme")

but for test i am always getting null can somebody tell me what i have done wrong i am using swift language or there is a another way to create a settings view for custom keyboards

1

There are 1 answers

1
Shripada On

From Documentation

....

To enable data sharing, use Xcode or the Developer portal to enable app groups for the containing app and its contained app extensions. Next, register the app group in the portal and specify the app group to use in the containing app. To learn about working with app groups, see Adding an App to an App Group. ....

I think in your case, this is not set up properly?