nsuserdefaults

How to save array to NSUserDefaults?

I would like to save an array of view controllers in NSUserDefaults, but I am not sure how: [[NSUserDefaults standardUserDefaults] setObject:tabBarController.viewControllers forKey:@"tabOrder"]; When I read the above line, my tabBarController.viewControllers is blank. ...

assignment makes pointer from integer without a cast

I don't understand what is problem here! after I compile it, always show me: "assignment makes pointer from integer without a cast" I don't know what is the problem! Please let me, thanks. SAVE NSUserDefaults *percentChecker = [NSUserDefaults standardUserDefaults]; [percentChecker setInteger:0 forKey:percentCheckerSaveKey]; LOAD...

UIPickerView and NSUserDefaults issue

Hi, I have an UIPickerView with 2 components. I would like to save the user's selection and to apply it next time the pickerView is shown again. Here's my code: - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { NSUserDefaults *pickerViewSelectionDefaults = [NSUserDef...

Delete all my NSUserDefaults that start with a certain word

[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"Dog*"]; Is there a way for me to "walk" through a list of all the userDefault values in my iPhone app, and only delete certain ones? I.E. All the keyNames that start with a certain word. ...

ios 4 check for settings change wi-fi active

hi there, in my application I need the wi-fi set to deactive. so when the app starts I verify the status and call the corresponding screen telling the user to put off the wi-fi. in ios4 the user may change to the settings without leaving the application. I yet included the NSNotificationCenter *center = [NSNotificationCenter defaultCe...

NSUserDefaults & bindings.

Hi, How can I synchronize two interface elements and have the value saved at termination? I connected a checkbox' state and a text field's enabled to an NSObjectController. The "content" outlet is connected to the checkbox too. (Not sure why?). It works with the NSObjectController but whenever I bind the value's to an NSUserDefaultsCont...

NSCoding with as NSString inside a object

My issue is then i retrive my NSArray of Store objects, all my NSString properties are giving me BadAccess errors. The int and double works fine! store.h @interface Store : NSObject<NSCoding> { NSString *Name; NSString *Address; NSString *Phone; double GeoLong; double GeoLat; int ID; } @property (nona...

How to save entire class to NSUserDefaults?

I have a custom class full of BOOLs, ints, NSStrings, NSMutableArrays etc. Is there a way to save the class as a whole to NSUserDefaults (and load it)? If so, how would I do it? ...

NSUserDefaults BOOL returning (null)

Hi guys, I'm trying to pull an NSUserDefaults value from a Settings.bundle into my application. When I load up the NSUserDefaults on application load, though, an NSLog reveals that my BOOL value returns "(null)" and my String value returns the number 39540360. The weird thing is that the documentation on NSUserDefaults specifically state...

How to delete data in userdefaults in iPhone when apps are uninstalled?

The NSUserDefaults class provides us a convenient way to store/restore shared data. But I got a question: how to delete data when user uninstalls the app? As we all know, apps should clean all its data/files when it's deleted. Leaving anything that won't be used anymore shouldn't happen, isn't it? As far as I know, an app will never know...

Get NSUSerDefaults Data from device

I have created an application in which I have used base64 encoding and save the user password into NSUSerDefaults, But somehow another iPhone developer breaks that password. I wonder how could he got NSUserDefaults Data? Does someone knows how to stop this critical thing and also how he had got the NSUserDefaults Data. Also what is the b...

Problem with UIPickerView selection and NSUserDefaults

Hi, I have an UIPickerView with 2 components. I save the user picker selection with NSUserDefaults. Both components have the save rows text. For some reason, it saves only the last selected row and apply it on the other component, for example: If I select row 0 in component 0 and then select row 1 in component 1, and try to access them...

[iphone] initial settings of NSUserDefaults

So I was reading this: http://stackoverflow.com/questions/2228302/storing-iphone-application-settings-in-app which seems simple enough. However, where/how would I define the initial settings? So for instance I have a Country setting: UK or USA. When the app is first installed/opened I want it to automatically know/set NSUserDefaults to...

how to save switch state with user defaults?

Hi, Is there a method to store the state of a UISwitch with NSUserDefaults? If the state is ON I'd like to set some action... Can I do this? Thanks! ...

How can I get one of my Preference Specifiers in the Settings Bundle to default to YES?

I've got a weird one when I test on the iPhone... I have a settings.bundle that has a Boolean for background_sounds which is set to YES by default. The problem is, when the app loads first time, the background_sounds pref seems to be set to NO when checked. I've tried synchronizing NSUserDefaults and everything, but the only way of makin...

force reset NSUserDefault on iPhone App upgrade

i want to force reset to NSUserDefault whenever user update my app. why i need this because every update include some new information abt user. as some info (token) already present in NSUserDefault my app does not call to my web service. due to that fact i dont have new user info. and also i dont want to write if..else statement for ever...

Observing value changes to an NSUserDefaults key

Hi, I'm interested in the value change of a particular key which I keep in NSUserdefaults. However, what I have is not working for me. observeValueForKeyPath does not get triggered. Update: I think I've discovered the issue. Rather than using a defined constant, if I use a string then it gets fired. [[NSUserDefaults standardUserDefau...

Can I save user's drafts using NSUserDefaults?

I am trying to save drafts using NSUserDefaults but I am not sure if it is the right place to save data not user's preferences in. My application allows user to choose 1 or 2 images to upload and share. Users can save draft and come back to upload later. My current approach is to save the chosen UIImage to /Library directory and save t...

iPhone NSUserDefault with Cocos2D

Hello. I've been working on a game for a bit, I'm now trying to get it working with OS4+. I'm struggling with saving data, my method worked perfectly for OS3. I have a singleton: #import "GameState.h" @implementation GameState @synthesize gStarted; @synthesize gLevel; static GameState* _sharedGameState = nil; +(GameState*)shared...

What does `standardUserDefaults` on `NSUserDefaults` do?

I have question related to NSUserDefaults's standardUserDefaults. What exactly does the standardUserDefaults method do? Is it initializing the object? ...