UserDefaults
在我的应用程序中不起作用。请在文件下找到以下代码AppDelegate
。
let sharingData = UserDefaults.init(suiteName: "group.macuser79.xxx");
sharingData?.set("vincenzo", forKey:"username");
sharingData?.synchronize();
在要监视的应用程序的 InterfaceController 中,为了能够检索值,我这样做了:
override func awake(withContext context: Any?) {
let sharingData = UserDefaults.init(suiteName: "group.macuser79.xxx");
let username = sharingData?.object(forKey: "username");
print("Value username \(username)");
}
请让我知道,我做错了什么!