Questions tagged [userdefaults]
507 questions
-2
votes
2 answers
How to save Singletone object in NSUserDefaults Swift2.3?
class AddBodyMeasurments
{
static let sharedInstance = AddBodyMeasurments()
var BodyMeasurements:AddMeasurment!
private init()
{
BodyMeasurements = AddMeasurment.init(json: [:])
}
func SaveValue(value:AddMeasurment)
…

Arjun Patel
- 1,394
- 14
- 23
-3
votes
1 answer
How to select a single image from an Array of Image Literals and save it to user defaults in swift 5
I am a very new Swift developer.
I have a global Array of Image Literals, displaying in an Image Scroll view.
I need a user to be able to select a single image and off a button, save it to user defaults.
Could someone please point me in the right…

Geno
- 37
- 7
-3
votes
2 answers
Not able to access data from Userdefaults - Swfit
I am accessing user default value as:
let data = UserDefaults.standard.object(forKey: identifier)
when I see the value in data it is visible as:
https://i.stack.imgur.com/UOjI8.png
type of data is
po type(of: data)
Swift.Optional .…

Rahul
- 5,594
- 7
- 38
- 92
-3
votes
3 answers
Set array of objects in UserDefaults
how to set and later get array of json objects in UserDefaults?
My application crashes when i try to set it as follow:
import SwiftyJSON
var finalArray = [JSON]()
UserDefaults.standard.set(finalArray, forKey: "attemptedArray")
my data looks…

Deepak Verma
- 373
- 7
- 19
-3
votes
1 answer
Clearing a subset of UserDefaults in Swift
The use case is that I want to separate my UserDefaults (different business logic may require Userdefaults to be grouped separately) by an identifier just like Android's SharedPreferences. For example, when a user in my app clicks on logout button,…

sandpat
- 1,478
- 12
- 30
-3
votes
1 answer
The best way to save data
So, here is my current issue: I simply want to save about 500 different strings.
My question then is what is the best way to do this?
All the strings are suppose to be loaded afterwards. The idea is that one label will be able to present all of…

albin öberg
- 7
- 2
-3
votes
2 answers
What's wrong with my UserDefault code for global Array?
Trying to store an array through UserDefault, but Xcode gives me an error. The error message is Thread 1: Signal SIGABRT, and the console says "NSInvalidArgumentException, reason: Attempt to insert non-property list object". I have previously stored…

Joakim Sjöstedt
- 824
- 2
- 9
- 18
-4
votes
5 answers
UserDefault for ios App
I am creating an app and I would like user to be logged in all the way after they register an account with the app until the user decides to delete the account.
It works something like whatsapp. Am i correct to use userdefault to store what the…

noob
- 11
- 5
-4
votes
1 answer
How to pass information from one controller to another using "UserDefaults.standard.set( )"
I am trying to pass the information from one controller to another controller. I have two controllers 1.ViewController 2.SecondController. I want to pass information from ViewController to SecondController using UserDefaults.standard.set where i am…

sindhu kopparati
- 223
- 1
- 3
- 7
-4
votes
1 answer
Value is always nil
I have a text field that will display ten strings in a chart. If textfield one has text then it will display on textfield 2, if textfield 2 has text then it will go to textfield 3 and so on. But for some reason it always display the string in…

Oren Edrich
- 674
- 1
- 7
- 23
-5
votes
1 answer
I get a error with my imagePickerViewController in swift 4
I get this error when calling my delegate method for my ImagepickerViewController
Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}
My delegate method is
func imagePickerController(_ picker:…

Golden Mamba
- 1
- 1
-5
votes
2 answers
Reduce UserDefaults Integer Value - Swift
Is there any way to reduce the UserDefaults integer key value?
This is my code to save it:
var highScore = UserDefaults().integer(forKey: "HIGHSCORE")
How could reduce this value by a fixed integer?
So reduce by 20 etc?

Alex Ingram
- 434
- 4
- 17