nsuserdefaults

Why NSUserDefaults failed to save NSMutableDictionary in iPhone SDK?

I'd like to save an NSMutableDictionary object in NSUserDefaults. The key type in NSMutableDictionary is NSString, the value type is NSArray, which contains a list of object which implements NSCoding. Per document, NSString and NSArray both are conform to NSCoding. I am getting error : -[NSUserDefaults setObject:forKey:]: Attempt to i...

Bind user defaults to different identifier

I have a preference pane bundle (it runs in the System Preferences). I designed the interface using Interface Builder where I binded a "start automatically" checkbox to the Shared User Defaults. This works great but it writes the preference to com.apple.systempreferences. I would like to keep my preferences in the com.example.mybundle de...

Save CoreData-entities in NSUserDefaults

Imagine an CoreData entity (e.g. named searchEngine). NSManagedObjectContext manages some "instances" of this entity. The end-user is going to be able to select his "standard searchEngine" with a NSPopupButton. The selected object of NSPopupButton should be binded to the NSUserDefaults. The problem: 1) @try{save} a) If yo...

Another question about iPhone application state

Hi, I have another question about restoring application state, on the iPhone. Simple data (like the selected tab) can be stored in NSUserDefaults, but it is not enough. I want to restore the whole state, including the Navigation Controllers (go to the sub-sub-sub View Controller). My problem is that my application is divided in severa...

KVO and Bindings problems using my own (not the shared) NSUserDefaults object

I'm subclassing NSUserDefaults in my application. A side effect of this is I can't use [NSUserDefaults sharedUserDefaults], I have to have a class method to provide my own static defaults object. This isn't been a problem in code, but it's proving tricky now that I'm hooking up the preferences UI with bindings. The shared NSUserDefaults...

Is it possible to use Cocoa's Bindings to have an editable NSTableView hooked up to an NSMutableArray?

It seems from the bits and pieces I can scrape together that the answer to this one will be "no", so I'll broadly explain what I'm trying to achieve in (the likely) case that I'm trying to hammer in a screw. What I have in my app is a list of valid file extensions to read in, which I'm recursing through a directory for. I want this to b...

Ist it a good idea to use NSUserDefaults to store the latest state of an iPhone application?

I have an view-based application where the user can do a lot of customization things, like selecting colors, selecting pictures, and so on. First, I thought about using sqlite3 for that, but since this would result in a table with only one row (no multi-user app), it seems like a big overhead to me. Then I heard about NSUserDefaults. Bu...

NSUserDefaults: What's the +resetStandardUserDefaults method good for? How can I provide "system settings"?

I want the user to be able to make some preferences like colors, prefered images, etc. When I use NSUserDefaults for this, on first start of the app there will be no preferences, right? So, every time I want to get a preference like NSInteger avatarID = (NSInteger)[[NSUserDefaults standardUserDefaults] objectForKey:@"avatar"]; I have t...

How can I reset the NSUserDefaults data in the iPhone simulator?

I've added NSUserDefault data retrieval to my app, which is pretty nice. But for testing I would like to reset all the data I added to the defaults database, so that everything is in the state when the user launches the app the first time. I tried to call: [NSUserDefaults resetStandardUserDefaults]; but that doesn't do anything. The d...

EXC_BAD_ACCESS trying to read an NSArray

In the following code, I try to read data from a plist: -(void)readPreferences { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSMutableArray * myAppDefaults = [defaults mutableArrayValueForKey:@"LastList"]; myCustomObject * savedObject; NSUInteger i; for (i = 0; i < [my...

Why do these errors in Xcode Mean?

2009-07-06 06:49:13.666 Spark[9825:10b] -[<NSUserDefaultsController 0x137af0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key hotKeyDisplayEntry. 2009-07-06 06:49:13.667 Spark[9825:10b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSUserDefaultsController 0x137...

iPhone sdk: I'm trying to increase an integer by 10 and failing

(Problem solved now, see answers below) Hello, in my app I am trying to create a points counter. That increases a number by 10 every time a button is pressed. I successfully managed to get my app to increase a value (0) by 1 every time a button is pressed, and to remember the latest value and display it next time the app starts. But w...

UserDefaults in system preference pane installed for multiple users in OSX...

Hi I have a background-only app that is controlled via a preference pane in the system preferences. To communicate between pref pane and app I use distributed notifications. User defaults are shared via [NSUserDefaults addSuiteNamed:]. This all works out very well. The problem occurs when the user installs the pref pane "for all users"...

iPhone SDK NSUserDefaults not saving correct values

I could use some help. After a few frustrating days of trial and error, I'm getting inconsistent results writing preferences to NSUserDefaults. Here are the consecutive lines of code: NSLog(@"startTimer(): End Time defaults: %f\n", [defaults floatForKey:kEndTimeKey]); NSLog(@"startTimer(): new End Time: %f\n", endTime); [defaul...

Archiving and Unarchiving results in Bad Access.

I'm having trouble setting up a model object to save the visual state of user generated CALayers in a simple graphics application for the iphone. I'm attempting to save the background color and frame of all the current layers on screen by passing those properties to model objects which implement the NSCoding protocol and then into an NS...

how can i store value in an NSArray using WritetoFile?

i wana store the index of seleted cell of table using NSArray, can u help me.... ...

passing command line arguments (NSArgumentDomain) to program under Xcode

I'd like to be able to pass command line arguments to programs that are run/debugged under Xcode. I want to do this so that I can command-line enable debug modes using Cocoa's NSUserDefaults and NSArgumentDomain. How to do that? Thanks! ...

When does application state belong in Core Data instead of NSUserDefaults?

I'm trying to decide whether some application state, specifically the selected item in a list, should be stored in Core Data or NSUserDefaults. Generally I believe that application preferences and state should persist in NSUserDefaults, and model-level data should persist elsewhere, say in Core Data. My model so far is: Should the dat...

iPhone Objective C : Saving & Loading UIColor into & from NSUserDefaults

What's the easiest way to save UIColor into NSUserDefaults ? And how to re-create it from NSUserDefaults? Many thanks for reading ...

Change objects in NSUserDefaults without creating and re-setting copies

I've got dictionary stored in NSUserDefaults and I need to add/remove items in this dictionary. It bothers me that to do this I have to create mutable copy of entire dictionary, change one element and replace entire dictionary with new copy. copy = [[defaults objectForKey:@"foo"] mutableCopy]; [copy setObject:… forKey:@"bar"]; [default...