简体   繁体   English

西装名称为swift的NSUserDefaults

[英]NSUserDefaults with suit name swift

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 我使用swift为ios创建了一个自定义键盘,我需要添加一个设置页面,因此我尝试在容器应用程序和键盘应用程序之间传递数据,我在AppGroups中添加了AppGroups,这是我使用的代码

in container app view controller 在容器应用程序视图控制器中

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

and in UIInputViewController class 并在UIInputViewController类中

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 但是为了进行test我总是得到null,有人可以告诉我我做错了什么吗?我使用的是快速语言,或者还有另一种方法可以为自定义键盘创建设置视图

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. 要启用数据共享,请使用Xcode或Developer门户为包含的应用程序及其包含的应用程序扩展名启用应用程序组。 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? 我认为在您的情况下,此设置是否正确?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM