nsuserdefaults

Do iPhone app settings have to be shown in the iPhone system settings?

If I'm using NSUserDefaults to store settings for my application, is there any way to make my app's settings "hidden" from being shown in the general Settings application on the iPhone? I know there are other tools out there such as mySettings, Keychain, etc, but I'm just wondering if there is a flag somewhere that says 'do not show my s...

OS X Data Storage in PLIST Example or Tutorial?

I have looked for several hours for a good tutorial on how to store data for my command line program that I am writing in Objective-C. It seems like my options are NSUserDefaults, Plists, sqlite, or XML. Now, I think at most I'd have 50kb of data to store, retrieve, and modify, so it seems like from what I read Plists would work just f...

Where's the best place to put your NSUserDefault save/load code?

Using NSUserDefaults to save/load a few small values... it's pretty straightforward. But WHERE would I place my SAVE or LOAD code? I want the defaults to LOAD only if/when a certain view is displayed. I want the defaults to SAVE, only when that view is exited/unloaded/hidden. (I created a simple app using the "view-based template" an...

How to Recreate the Last State of an App the Next Time it is Launched?

I have 2 views. When I'm on the 1st view, I have a textfield. I enter some text in the textfield. I exit the app, launch some another application and then return to my application. I want to maintain state of the textfield and that view. Likewise, if I quit with the 2nd view active, when I return to the app I need to return the view to t...

Objective C - Problem with objectForKey

Okay, I'm trying to write a high score function for my app. My problem is that when no high score has been saved yet, my program crashes. If I save it with: [[NSUserDefaults standardUserDefaults] setObject:@"[given string]" forKey:@"firstName"]; first, it works fine. However, if I start up the program for the first time and try to ...

How to persist a checkmark with a table populated by a plist?

Hi all, I have an app where when the user taps on a cell I would like for a check mark to appear and be persisted. So far this is my code. -(void)viewDidLoad { [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@"AirportList" ofType:@"plist"]; NSMutableArray *airArray = [[NSMutableArray alloc] initWithContent...

NSKeyedArchiver/NSuserDefaults - saving a CGRect

Hi everyone! My app involves a user being able to drag specific items such as volume sliders and UIImage views. My goal is to be able to save the locations of the items so that the user can not have to drag the items again after re-launch. Unfortunately, I have seen errors along taking the 'saving CGRect rect = item.frame to NSuserDef...

Register/Set a new language default

Hello, My app has some languages that the user can change whenever wants. The problem is that always uses the current device language selected, so at least my localizable strings are working as expected, but no matter wich language I set, I'm getting alwats the default selected of the device. Where I have to call this code? [[NSUserD...

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 number and check this when the app is launched but it has quickly become very messy as I have ...

How to store custom objects in NSUserDefaults

Alright, so I've been doing some poking around, and I realize my problem, but I don't know how to fix it. I have made a custom class to hold some data. I make objects for this class, and I need to them to last between sessions. Before I was putting all my information in NSUserDefaults, but this isn't working. -[NSUserDefaults setObje...

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

Hello, 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 ...

NSUserDefault exists -iPHONE SDK

Hello everyone, 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 ...

Problem with NSUserDefaults and deallocated Instance

Hi, I'm having a problem with NSUserDefaults. I've followed the steps in the books as closely as I can for my app, but still get the same problem. I am getting a *** -[NSUserDefaults integerForKey:]: message sent to deallocated instance 0x3b375a0 error when I try and load in the settings. Here is the code that I have, it is in the...

Using NSUserDefaults how to save a key before app is first run

I have an app where I need a BOOL value to persist across launches. The value should be YES on the first launch and user-customizable thereafter. But if it's the first launch, how do I set the default to YES before the program is run? ...

How to retrieve stored reference to an NSManagedObject subclass?

Hi! I have a NSManagedObject subclass named Tour. I stored the reference to it using this code: prefs = [NSUserDefaults standardUserDefaults]; NSURL *myURL = [[myTour objectID] URIRepresentation]; NSData *uriData = [NSKeyedArchiver archivedDataWithRootObject:myURL]; [prefs setObject:uriData forKey:@"tour"]; Now I want to retrie...

Trouble with data not saving with bindings and shared NSUserDefaults in IB

I'm having a bit of a strange issue that I can't quite figure out. I'm somewhat of a n00b to Interface Builder. What I am trying to do seems like it should be simple, but it's not working for some reason. In interface builder I have a preferences window with a simple NSTextField. I have set the value binding to the Shared User Defaults ...

how to make NSUserDefaults show in Setting on iPhone?

according to this image, i try to save data in NSUserDefaults but my App not have application setting in menu Setting on iPhone? how can i make this? thanks. ...

Why can't I save changes to application settings with NSUserDefaults?

I am using the following code to save values from a settings view that takes values from a UITextField and stores them with NSUserDefaults. The code below even calls synchronize yet it is not saving the changes. What am I doing wrong here? - (IBAction)save { NSLog(@"save"); NSUserDefaults *defaults = [NSUserDefaults standardUse...

iPhone SDK: NSUserDefaults or NSDictionary?

Compare the following: using NSUserDefaults saving it with synchronize using NSDictionary saving it with writeToFile in the app Documents folder What are the differences? Personally, I prefer to mantain different NSDictionary organized by topic rather than use a single NSUserDefaults. Am I thinking something wrong? Thanks ...

How to check existence of reference to an NSManagedObject?

I successfully stored and retrieved a reference to an NSManagedObject using the example found in this site http://cocoawithlove.com/2008/08/safely-fetching-nsmanagedobject-by-uri.html The problem is, the app crash whene triying to retrieve an NSManagedObject which has been deleted. I tried the method isFault on the object, but it alway...