nsuserdefaults

NSUserDefaults limit integer?

Hey guys, 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. ...

Tell The Program What To Do When No Save Data Is Found NSUserDefaults, iPhone

Hello all, I have saved data which was saved using NSUserDefaults. I was under the impression that if there was nothing saved to the key already (first time app is run) it would default to 0. This however doesn't seem to be the case. Here is what I have: To save: - (void)viewWillDisappear:(BOOL)animated { [[NSUserDefaults standardUser...

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

Hello, I have created window based application. Tab bar controller as root controller and it has three tabs. One Tab has Labels and TextFiled inputs like Name, Username and Password. I am looking to store this text filed inputs when user enters and able retrieve in other tabs. Previously I have set key for different text fields and se...

How to create Dictionary object in AppDelegate to access objectkey in another ViewController

Hello, I have created Window Based application and tab bar controller as root controller. My objective is to store Text Field data values in one tab bar VC and will be accessible and editable by other VC and also retrievable when application start. I am looking to use NSDictionary class in AppDelegate so that I can access stroed Data V...

execute code only once in objective c. not every time the app launches

I want to delete a table from a sqlite3 db at certain times, i.e. after its been uploaded to a server. i want to set a flag that will mean the table does not get deleted the first time the app is launched. after that the logic will take care of when the table in the db is deleted. i'm currently using nsuserdefaults to set a flag which...

can appcelerator use NSUserDefaults on iphone?

I'm trying out the version 1.2 appcelerator and wanted to use the NSUserDefaults with it... has anyone tried that before?? I can find it in the docs... :{ thanks!! ...

Save a UIImageView using NSUSerDefaults

How do you save an Image using NSUSerDefaults The main image is set in IB, the secondary image is set here - (IBAction) changeImage { CATransition *fadeThing = [CATransition animation]; fadeThing.type = kCATransitionFade; fadeThing.subtype = kCATransitionFade; fadeThing.duration = 1; [CATransaction begin]; [background.layer ad...

NSUserDefaults in logic test

Does NSUserDefaults work in logic tests or only in/on simulator/hardware? ...

IPhone SDK Default NSUserDefaults...

I have set up the user defaults to record a integer for a UISlider, the problem is that, if the user has only just installed the app then the integer is zero or NULL. Is there a way to detect if it = NULL with a integer? heres my code i have so far: -(void)awakeFromNib { NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; se...

iPhone - User Defaults and UIImages

Hello, I've been developing an iPhone app for the last few months. Recently I wanted to up performance and cache a few of the images that are used in the UI. The images are downloaded randomly from the web by the user so I can't add specific images to the project. I'm also already using NSUserDefaults to save other info within the app. ...

How to store UISegmentedControle state in NSUserdefaults

The problem is when de selectedSegmentIndex is unselected: "UISegmentedControlNoSegment" alias "-1". The other states (0, 1, 2 , etc.), I can store as Integers and retrieve with carTypeSegmentedControl.selectedSegmentIndex = [defaults integerForKey:@"typeOfCar"]; But -1 is no NSInteger. I also tried to remove the Integer out of th...

NSUserDefaults always returns 0, in Simulator and Device

I have a settings bundle in my iPhone app, with the following PList: Type: PSMultiValueSpecifier Title: Within (Kilometres) DefaultValue: Number: 1 Titles: Array: Item 1: Number: 1 Item 2: Number: 2 Values: Array: Item 1: Number: 1 Item 2: Number: 2 Key: String: km Then in my code i have: NSUserDefaults *defaults = [...

UIImagePickerController Causes my app to crash!

In my app, a user can select an image, change the picture of a UIImageView to the new imge, and save the image to NSUserDefaults using NSKeyedArchiver. When the user selects the image and the - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info is called, the app immediately ...

how and where should I set and load NSUserDefaults in a utility app?

I have followed directions in several books and suggestions on some forums but I have issues with my app crashing when I try and set user preferences. I have the following lines on my "done" method in my flipscreenViewController: - (IBAction)done { NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; [...

NSUserDefaults: Saved Number Always 0, iPhone

Hello all, I have looked at other answers and the docs. Maybe I am missing something, or maybe I have another issue. I am trying to save a number on exiting the app, and then when the app is loaded I want to check if this value exists and take action accordingly. This is what I have tried: To save on exiting: - (void)applicationWillTe...

Storing arrays in NSUserDefaultsController

Currently I use NSUserDefaults and I'm interested in using NSUserDefaultsController, so that I get notifications when things change. Below is my current code. items = /* NSArray of MYItem's */; NSData* data = [NSKeyedArchiver archivedDataWithRootObject:items]; [[NSUserDefaults standardUserDefaults] setObject:data forKey:kMYItems]; Ho...

Cannot read values from [NSUserDefaults standardUserDefaults] after synchronize

In the Application Delegate didFinishLaunching method, I am using the following code to build up a new NSDictionary to be used as the new settings bundle for the user: NSNumber *testValue = (NSNumber*)[[NSUserDefaults standardUserDefaults] objectForKey:@"settingsversion"]; if (testValue == nil) { NSNumber *numNewDB = [NSNumber numbe...

Recording purchased products from in-app store for built-in products

I'm creating an in-app store for a few built-in features for my iphone app. Apple's documention recommends using the Application Preferences for storing this, but another question in this forum suggested using NSUserDefaults for another task for which Application Preferences was recommended (by Apple). Can someone clarify if, for in-ap...

How to check a bool setting in my iphone app

I have a setting in Root.plist with Key = 'latestNews' of type PSToggleSwitchSpecifier and DefaultValue as a boolean that is checked. If I understand that correctly, it should = YES when I pull it in to my code. I'm trying to check that value and set an int var to pass it to my php script. What is happening is that my boolean is either n...

NSUserDefaults not present on first run on simulator

I've got some settings saved in my Settings.bundle, and I try to use them in application:didFinishLaunchingWithOptions, but on a first run on the simulator accessing objects by key always returns nil (or 0 in the case of ints). Once I go to the settings screen and then exit, they work fine for every run thereafter. What's going on? Is...