Swift 3 / iOS 10 / TodayExtension - UserDefaults always returns nil
I partially solved my problem.
I have completely remove Xcode and all the settings (caches files etc...),
then I have removed the "Team" part in the suite name.
Now I have like a warning in the Xcode console but I can retrieve my notes in my TodayExtension. Piouf !
I still have the problem for WatchKit Extension. I'm not sure but I think that I have read that UserDefaults even with App Groups are not shared with Apple Watch Extensions.
But Apple write in their documentation "Also, iOS automatically forwards a read-only copy of your iOS app’s preferences to Apple Watch. Your WatchKit extension can read those preferences using an NSUserDefaults object, but it cannot make changes directly to the defaults database."
So I don't know why I cannot retrieve my notes from my Apple Watch.
At least I have solved my first problem. If anybody has the same.
NSUserDefaults Multi Value is nil
You're querying for a dictionary value, but there's only a String stored in UserDefaults
.
Use let stage = UserDefaults.standard.string(forKey: "stageSelection")
UserDefaults between iOS and WatchOS not working
Communication between watchKit and app using userDefaults has been removed.
It can be done using watchConnectivity framework
Save dictionary in userdefaults in swift 3 with xcode 8
This problem seems to be caused by having two versions of xcode/simulator installed.
What worked for me was uninstalling xcode 7 and just keeping xcode 8 beta on my system. Emptying trash, resetting the simulator and running. I also restarted my computer.
After following these steps the simulator is able to save to UserDefaults.
Related Topics
Swift Spritekit Get Visible Frame Size
Read UId from Nfc Mifare Tag iOS 13
Swift3 Different Font in The All of The UIview with Localization Each
Heightanchor.Constraint Not Change Height of View
Programmatically Select All Cells in Tableview So Next Time They Are Pressed They Call Diddeselect
Type Alias Declaration with Templates in Swift
Why My Arguments Are Being Blocked When Running a Shell Command
Why Is There Multiple Collision Calls Sprite Kit Swift
Swift Compound Arithmetic Operation Error
Swift: Gradient Splits on Rotation
How to Properly Map JSON Properties to Model Properties in Realm.Create
Nsattributedstring Boundingrect Returns Wrong Height
How to Get The Range of The First Line in a String
Create Objects/Instances in Variables Swift
Extending Dictionary with Key and Value Constraints
Swift: Handling an Unexpected Nil Value, When Variable Is Not Optional