nsuserdefaults

Why won't my NSUserDefaults load?

So I have an iphone app that presents a modal view when it starts if the user has not registered. Once they register, it saves a user ID into NSUserDefaults. When the app starts at a later time, it needs to load this user id in the appdelegate file. //Registration.m NSUserDefaults *savedUID = [NSUserDefaults standardUserDefaults]; [save...

How to get an update NSUserDefault on iOS 4?

Hello I am developing an iPhone application, I encounter a problem on the iOS4 because of multi task. This application has the default settings defined in a Settings.bundle. If I run my application then I left it (so it goes in the background). I'll change the settings and restarts the application (it comes out of standby and method: a...

problem in viewDidLoad..can i call presentModelViewController in viewDidLoad..?

Hi.. i am new to iPhone Programming. In my app i have HomeViewController and ContentViewController. i am saving the values in ContentViewController by using NSUserDefaults and based on saved values i will load the ContentView instead of HomeView when the app is restarted. if there r no values in the NSUserDefautls it displays the HomeVie...

Memory issues with NSUserDefaults

I have spent hours trying to get my project working and I just can't get it working. Basically, I'm trying to use NSUserDefaults to save a custom object when the user hits a save button and load all the data up when the app loads. If there is no previous NSUserDefault saved, I want to set some defaults. In the end, I am getting EXC_BA...

How to recover the app settings in NSUserDefaults from a dictionary returned by -dictionaryRepresentation ?

I'm getting a dictionary representation of the current settings in NSUserDefaults, as NSDictionary. That was pretty easy using the -dictionaryRepresentation method. However, I need to write that back again. I couldn't find a method to do that easily. Maybe it's just too hot in my office? ...

How to tell if iPhone application was launched by backgrounding or not.

My application uses NSUserDefaults to store some values so that it can restore them on application update or if backgrounding is quit. Backgrounding automatically saves my integer values, but if the user quits the application from the launcher, the numbers are lost too, and the ViewDidUnload method I guess doesn't evoke when entering bac...

NSUserDefaults flexibility for version updates

Hi, I am using the NSUserDefaults' api -registerDefaults api to register the factory defaults of my application. All is fine for the first version of the application. But when I provide an update for the iPhone application, I have 3 criteria to make sure: The user preferences of older version app should be intact. Addition to the fact...

Re-order an array

I have a list of bookmarks stored in NSUserDefaults. For each bookmark entry I retreive data from a sqlite database. I then create an array of these bookmarks. Each bookmark in the array is represented as a person object. How ca I re-order the array to sort by the persons first name? ...

core data for 'add to favorites' button?

i've had difficulty finding examples/tutorials/information for this. i'd like to have an 'add to favorites' button in my application. this would take a cell from one tableview and populate that cell into the 'favorites' tableview. is core data the proper direction for approaching this? i've seen some hints about using nsmutablearray and/...

Retrieving an int from NSUserDefaults

How do I retrieve an int from NSUserDefaults? I have the following code NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; NSArray *prefs = [def arrayForKey:@"addedFavs"]; favList = [[NSMutableArray alloc] initWithArray:prefs]; If I try this NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; int tempInt = [de...

iPhone preferences (NSUserDefaults) not working, keys always return nil!

I made some preferences in my Settings.bundle that show up fine in the Settings app. However my settings always return nil when I read them back. I know I need to set a default value on first startup. But even after that and going to the settings menu (which should also set the default values) - when I read them back I always get nil...

NSUserDefaults and read-only value

Is there a way to make some value of my preferences stored in the iPhone Application Settings to be read-only. Let say that for some reasons I do not want the user to be able to modify some values. Is possibile? Thanks ...

NSUserDefaults wiped out after several sessions, Possible?

Hi all, I'm storing certain values in NSUserDefaults, but after several sessions, I find nil values for those variables whenever I'm retrieving them. It's nowhere that I'm resetting them in my whole program. How can this happen? Thanx in advance. ...

Settings Application Implementation - boolean values set to "no" by default.

The question, by itself, implies that the DefaultValue property in my Root.plist file was set to "no". This is unfortunately not true. To verify what my problem is, I am trying to use a section of the iPhone's Settings application. I am using this to show/hide certain on-screen items. By default, the "shown" property was set to "on."...

Is NSUserDefaults the correct place to store a list of favorites?

Hi, I am programming an app for iOS, allowing the user to make connections via tcp/ip. The user is able to save a server as a favorite. To make this possible I am serialising the server object and storing it to the NSUserDefaults. Is this the correct way to go or should I rather save the serialised object to the file system? Thanks, M...

problem with user defaults when saving a game... (int array)

hi! i have a problem with saving something and am officially out of ideas. what i want to do is save an integer array into the userDefaults, then when restarting the app loading this array and restart the game from this last point. what i do is that after each turn my AI logic saves the actual game state into an array -> so far so goo...

Objective-C NSUserDefaults: HighScoreManager, why doesn't this work?

My app won't save the data or load the data, it just crashes, I wonder what I'm doing wrong in my High Score Manager class. I'm going to post my class's .h and .m file: .h #import <Foundation/Foundation.h> @interface Score : NSObject { NSString *name; NSNumber *score; } @property (assign, nonatomic) NSString *name; @property...

NSUserDefaults changing values between launches

I have the following code in my applicationWillTerminate in the app delegate: NSLog(@"Source: %d", [[NSUserDefaults standardUserDefaults] integerForKey:@"Source"]); And I have the same code in my applicationDidFinishLaunching in the same app delegate. When I quit the app, the log shows one value (say 101) and when I relaunch the app,...

root.plist changes not visible on iphone

Hi, when i add new entries to my settings bundle root.plist file, build and run the app, the new settings are not visible within the app. I've of course used a unique key for the new entries. In my root.plist file in the xcode project the file shows the changes, but when i get the current file from the iphone via the organizer, the cha...

Saving data when navigating

how can i save the data in from texfield when i navigate back to previous view? i have set the app to save all data to plist when terminate but i when i am navigating up and down view, i need to save the data to some place. any suggestion? save data when "back" button at nav bar is press? but how? save to NSUserDefaults? ...