nsuserdefaults Questions

6

Solved

I'm using a tuple to store something like this. var accessLavels: (hasInventoryAccess: Bool, hasPayrolAccess: Bool) accessLavels = (hasInventoryAccess: true, hasPayrolAccess: false) Now I want t...
Kilimanjaro asked 12/1, 2015 at 6:44

4

Solved

I have a litle problem with saving a color in NSUserDefaults . In objective-c is easy : -(NSColor *)colorForKey:(NSString *)key{ NSData *data; NSColor *color; data = [[NSUserDefaults standardUser...
Plumbo asked 20/10, 2014 at 11:15

3

Solved

I'm testing a class that depends on an instance of UserDefaults. In following this sample code found here, I create and setup the instance like so: override func setUp() { super.setUp() defaults ...
Known asked 18/5, 2021 at 16:35

5

I'm trying to use the UserDefaults to persistently save a boolean value. This is my code : public static var isOffline = UserDefaults.standard.bool(forKey: "isOffline") { didSet { print...
Seethrough asked 23/12, 2016 at 13:2

6

Solved

This code will call the method "defaultsChanged", when some value in UserDefaults changed NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center addObserver:self selector:@s...
Speedwell asked 3/6, 2012 at 16:8

9

Solved

in my iOS project I need to save an entire JSON as user data and then reload it on next app launch. Squashing it into many values and then recreate the JSON is not an option, I just need some seria...
Spiritualty asked 3/3, 2016 at 17:59

11

I have a switch called soundSwitch, I'm saving the state of the button using a UserDefault as such: @IBAction func soundsChanged(sender: AnyObject) { if soundSwitch.on { defaults.setBool(true, fo...
Dracula asked 15/6, 2016 at 8:52

1

I have a messaging app where I use an app extension to be able to look up contact information when I receive an APN containing a new message. I exchange the Addressbook contacts info which I have s...
Tientiena asked 8/2, 2021 at 16:11

3

Solved

I'm trying to store a custom data type into AppStorage. To do so, the model conforms to RawRepresentable (followed this tutorial). It's working fine, but when I initialize the @AppStorage variable,...
Teletypesetter asked 5/1, 2021 at 23:15

13

Solved

I'm currently working on a iOS app developed in Swift and I need to store some user-created content on the device but I can't seem to find a simple and quick way to store/receive the users content ...
Assumptive asked 20/2, 2015 at 11:46

16

Solved

How can I use UserDefaults to save/retrieve strings, booleans and other data in Swift?
Dope asked 3/7, 2015 at 9:26

2

Solved

So I've been looking around and following all the steps to setup shared UserDefaults correctly but I should be missing something. I have App Groups capability activated on both my app and my exten...
Keane asked 16/10, 2016 at 0:36

6

Solved

I am having a problem in my sprite kit app where my NSUserDefaults variable is not working. In createSceneContents (which I know is being called) if (![defaults objectForKey:@"obj"]) { difficulty...
Tabloid asked 19/2, 2014 at 0:9

4

Solved

I am able to store, retrieve, and remove values using NSUserDefaults. I couldn't succeed to find out where NSUserDefaults getting stored physically on iPhone? I guess it should be plist file but no...
Lauds asked 12/7, 2011 at 10:21

4

My app has an option that allows the user to choose between the standard "full-size" window titlebar/toolbar and the "compact" titlebar/toolbar made available in the NSWindow 10.10 API. Specificall...
Broomrape asked 12/11, 2014 at 6:11

7

Solved

Can you see the values of NSUserDefaults naywhere in the xcode debugger? Just wondering if this is possible? Thanks, Nick
Bags asked 14/6, 2010 at 18:22

2

Solved

How can I use @AppStorage for a string map in a SwiftUI app? This is what I want to do: @AppStorage("ratings") var ratings: [String: Double] = [] But this gives me the error message “No ...
Bocanegra asked 26/6, 2020 at 20:21

2

Solved

Is there a difference between UserDefaults() and UserDefaults.standard in Swift 3.0?
Alwitt asked 13/10, 2016 at 16:19

3

Solved

With due reference: https://github.com/apple/swift-evolution/blob/master/proposals/0258-property-wrappers.md#user-defaults We've started to use property wrappers for the UserDefaults, it wor...
Carnival asked 10/10, 2019 at 7:33

1

I'm trying to be good and writing unit tests for my classes, but I have some classes that deal with preferences and checking for first run. The test functions I've written work fine the first time ...
Outsoar asked 28/9, 2016 at 3:53

2

Solved

I have 2 functions where one basically retrieves string in User Defaults and another writes the string in User Defaults. I'm not able to understand that should I do the unit test or no? and I'm pre...
Sociology asked 22/1, 2020 at 2:8

4

I have an custom struct called 'News' that I want to append into the array to NSUserDefault. But it's showing error "Type 'News' does not conform to protocol 'AnyObject'". I don't want to ch...
Jessamyn asked 16/7, 2016 at 0:0

7

struct ContentView: View { @State var settingsConfiguration: Settings struct Settings { var passwordLength: Double = 20 var moreSpecialCharacters: Bool = false var specialCharacters: Bool = fal...
Oho asked 30/6, 2019 at 3:20

2

I have an iOS app where we can login and I'm using user defaults to store data like "firstLogin", "freshInstall", "userName", "sessionTime", etc. I am gettin...
Acetamide asked 22/9, 2021 at 12:55

5

Solved

You can get a list of the keyboards installed on the iOS device using: NSUserDefaults *userDeafaults = [NSUserDefaults standardUserDefaults]; NSDictionary * userDefaultsDict = [userDeafaults dicti...
Forbearance asked 2/10, 2014 at 1:48

© 2022 - 2025 — McMap. All rights reserved.