Questions tagged [nsuserdefaults]

NSUserDefaults is the Objective-C API for storing and retrieving user preferences in Apple's Foundation framework for Cocoa and Cocoa Touch. It is available in OS X v10.0 and later and Available in iOS 2.0 and later which is inherited from NSObject root class

NSUserDefaults provides a cross-process hierarchical key-value store for use in Cocoa and Cocoa Touch applications. It is equivalent to and compatible with the CFPreferences C API in CoreFoundation.

This class provides a programmatic interface for interacting with the defaults system.At runtime, NSUserDefaults object is used to read the defaults that an application uses from a user’s defaults database. NSUserDefaults caches the information to avoid having to open the user’s defaults database each time you need a default value . The questions related to this can be tagged with

Source:

Question related to this are:

  1. iOS: How to store username/password within an app?

  2. Clearing NSUserDefaults

  3. How to store custom objects in NSUserDefaults

  4. Easy way to see saved NSUserDefaults?

3775 questions
1
vote
1 answer

Saving highscores with NSUserDefaults

I'm trying to save the highscore of my game. I'm trying to do this via NSUserDefaults. This is the code I'm using: //To save highest score var highestScore:Int = 20 NSUserDefaults.standardUserDefaults().setObject(highestScore,…
Raul Gonzalez
  • 875
  • 1
  • 10
  • 23
1
vote
0 answers

Core Data and User Defaults in Swift

I'm pretty new to programming and I'm working on my first app for the App Store. I have a data model working in Core Data, but I want to have a singleton for user settings and a reference to the current project. I'm having trouble getting a…
Steve Schwedt
  • 380
  • 2
  • 11
1
vote
0 answers

Disable iCloud backup for NSUserDefaults

This is probably a weird thing for me to want to do, but how does one disable the backup of NSUserDefaults to the cloud? I have used this successfully for data that can be redownloaded from the server, but looking for a way to use it against…
M Jesse
  • 2,213
  • 6
  • 31
  • 37
1
vote
2 answers

iOS8 custom keyboard can change theme on simulator but can't on the Real machine

I'm working on iOS8 custom keyboard, I want to change the keyboard's backgroung in this way: Set RequestsOpenAccess = YES; Settings: NSUserDefaults * usrInfo = [[NSUserDefaults alloc] initWithSuiteName:@"myKeyboard"]; [usrInfo…
SamSam
  • 113
  • 8
1
vote
1 answer

How to retrieve user input data entered tab bar View Controller when application start in iphone app

I have created window based application. Tab bar controller as root controller and it has three tabs. One Tab has Labels and TextField inputs like Name, Username and Password. I am looking to store this text filed inputs when user enters and able…
TechFusion
  • 41
  • 1
  • 11
1
vote
1 answer

NSUserDefaults is persistent?

I have a big problem with NSUserDefaults : I receive a feedback from an user who just updated the application from AppStore and he complained that some of the values from NSUserDefaults are gone. There is a little possibility that the NSUserDefaults…
Chirila Vasile
  • 359
  • 1
  • 2
  • 11
1
vote
1 answer

NSUserDefaults - Inserting array as object not working

Here is my code: NSMutableDictionary *newThoughtDict = [[NSMutableDictionary alloc] init]; [newThoughtDict setObject:self.triggerOne.text forKey:@"thought"]; [newThoughtDict setObject:self.date forKey:@"date"]; NSDate *currentDate = [[NSDate alloc]…
Broderick
  • 77
  • 6
1
vote
2 answers

Is there a better way to write this call to numerous NSUserDefault BOOLS?

I am tying to optimise my code and improve my programming. I am looking at this statement which get updated constantly. Is there a better way to right the calls to numerous BOOLS? Is it possible to include them in a FOR statement? baseballHat =…
Ben Thompson
  • 263
  • 2
  • 5
  • 12
1
vote
2 answers

Is NSUserDefaults the right choice for this app idea in swift

I have a super simple app idea that I'm building out in order to get more practices at using Swift. I just want to ask if using NSUserDefaults is the most appropriate choice. All I will have is list of names with a number associated with each name…
icekomo
  • 9,328
  • 7
  • 31
  • 59
1
vote
1 answer

NSUserDefault some times doesn't save itself

My app is getting bed reviews because users have to restore their purchase each time they enter the app... That drives me crazy because i don't have that problem on my iPhone. When transaction is made my app calls the following code: [self.data…
serg_ov
  • 563
  • 7
  • 18
1
vote
4 answers

Store a Dictionary in NSUserDefaults in Swift

I've got a Dictionary that I've created where the key is a String and the value is a custom object called SectorCoordinate. I just want to store the whole darn thing in NSUserDefaults, but when I do, Xcode says: The type [String, SectorCoordinate]…
Ben Carroll
  • 138
  • 2
  • 11
1
vote
1 answer

Storing data in NSUserdefaults or coredata?

I need to store a dictionary in my app It's life time should be as same as life time of the data stored in NSUserDefaults. There are few ways to achieve but I am thinking of core data, NSKeyedArchiever and NSUserDefaults. I am going to update…
jailani
  • 2,260
  • 2
  • 21
  • 45
1
vote
1 answer

NSUserDefaults objectForKey keeps returning nil, even when key exists

I'm trying to save data in NSUserDefaults. The very first time this code (and app) loops, it should go through the if-statement. Because no data was saved in NSUserdefaults was saved yet with the names: BoughtItem0, BoughtItem1, BoughtItem2,…
Viktor De Bock
  • 139
  • 1
  • 2
  • 17
1
vote
1 answer

NSUserDefaults limit integer?

Is it possible to limit an integer in the NSUserDefaults? Off course you can limit it within your app but I am thinking of the TextFields in Settings. Would be great to get some hints. Thanks a lot.
danielreiser
  • 5,292
  • 5
  • 31
  • 43
1
vote
2 answers

Save and load NSMutableArray - NSUserDefaults

I am trying to save a NSMutableArray to NSUserDefaults then reload it and use it to populate the button labels. Can someone please take a look and tell me what i am doing wrong here? When I am loading the file to new array it appears empty. All of…
burrGGG
  • 617
  • 2
  • 9
  • 18