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
4 answers

Detecting the first launch of an app with previous versions

I would like to update an app to add a tour on first launch. I would ordinarily handle this with some kind of NSUserDefaults key. However, there are pre-existing existing versions of the app already released. How can I trigger some behavior on first…
Ben Packard
  • 26,102
  • 25
  • 102
  • 183
1
vote
1 answer

IOS application Force to use English as Language

now my app needs to be running in english but when i run the application for the first time the default language of the device is used . i tried this code : @autoreleasepool { [[NSUserDefaults standardUserDefaults] setObject:nil…
1
vote
1 answer

How to store variables away from user access on iOS App

I want to store a variable that tells me if a user has made an InApp Purchase on the mobile device. NSUserDefaults seems to be accessible from users. Is there a simple and efficient way to do this ?
Patrick L.
  • 526
  • 6
  • 24
1
vote
1 answer

unable to open database file when passcode locks immediately

In the device settings,AutoLock is 5 minutes, and Passcode Lock is Immediatly. Suppose user clicked the power button of device when application is processing a large xml from server and insert/update database file. (the device will be in a locaked…
david
  • 66
  • 6
1
vote
0 answers

NSUserDefault doesn't work on real device(iPhone)

In my App, I am trying to implement SettingView by NSUserDefault. So, I wrote program code as follows: Method example of saving user setting: + (void)setUserAutoPlaySetting:(BOOL)setting { NSUserDefaults *userDefaults = [NSUserDefaults…
1
vote
1 answer

Saving multiple values to one NSUserDefaults key

I'm writing an alarm clock app, with a special twist to it. Not going to get into detail. Anyways, I'm trying to think of the best way to save the alarms. I figured, since its a pretty basic app, it wouldn't require core data. So I was going to…
Katushai
  • 1,510
  • 2
  • 14
  • 27
1
vote
0 answers

keyPathsForValuesAffecting for NSUserDefaults

I'd like to have a variable in my interface update automatically as other values change. I've used keyPathsForValuesAffecting which works perfectly fine for all the same variables in the same class. I can't get is to work if the variable is stored…
1
vote
2 answers

NSUserDefault exists -iPHONE SDK

How would I check in a "if" statement if the NSUserDefault object is saved there or not? I'm not really sure how to call it.. So a pretty short question.. Thanks
lab12
  • 6,400
  • 21
  • 68
  • 106
1
vote
3 answers

Always getting 0 for integer retrieved from NSUserDefaults

I have an integer stored in user defaults for my game's high score. Every time I start the game I want to check if the score is bigger than the previous high score, so I do this: NSUserDefaults *defaults = [NSUserDefaults…
codegirl
  • 15
  • 3
1
vote
1 answer

Attempt to set a non-property-list object only on iOS 7.1.1

Everything is OK but it's NOT on iOS 7.1.1 I don't know why. My objects I try to save are NSString or NSNumber (I checked each objects) Someone help me please! Attempt to set a non-property-list object ( { channel = "No Channel"; …
Tony
  • 4,311
  • 26
  • 49
1
vote
1 answer

NSUserDefaults Values and SQLite Database after update an app in the Appstore

What happens with the NSUserDefaults values and the SQLite database after updating the application in the appstore? Are they deleted or reseted or happens nothing with them? Alex
Herbel
  • 103
  • 1
  • 3
1
vote
1 answer

How to migrate NSUserDefaults in new release?

I have an iPhone app that stores some settings using NSUserDefault standardUserDefaults. When I add new features to the app I need to add new default settings and so I have to migrate/upgrade the NSUserDefaults. For now, I just store the version…
Rob
  • 13
  • 3
1
vote
3 answers

Is it ok to read a value stored in NSUserDefaults in multiple views

Is it ok to read a value stored in NSUserDefaults from multiple views or you only read it once and then you use another method to pass the data to different part of your app? In other words I want to know if I’m doing it right, what I’m currently…
fs_tigre
  • 10,650
  • 13
  • 73
  • 146
1
vote
1 answer

How To save Recorded audio to my app?

Please help me i tired to getting answer using following Answer in stackOverflow Ans 1 Ans 2 My code is - (IBAction)RecordBtnClicked:(UIButton *)sender { if (sender.isSelected) { if (!recorder.recording) { [session setActive:YES error:nil]; …
1
vote
2 answers

Where to store sensitive data

What is the best practice to store sensitive(not secure) data on iOS devices? Where should I store information that user bought something in app? For example where should I store BOOL showAds variable if user bought "Remove Ads"? I do understand…
user1561346
  • 502
  • 3
  • 13
  • 28
1 2 3
99
100