iPhone Xcode Settings.bundle Plist Help

I followed the tutorial: http://useyourloaf.com/blog/2010/5/18/adding-a-settings-bundle-to-an-iphone-app.html

And the "Shuffle Switch" (that I just created based on the tutorial) was not in the Settings App. Every time I did an NSLog on the state of the switch, it would return "(null)". The "Slideshow Switch" (which was created the same way) worked fine.

My Settings bundle Root.plist file looks as follows: (copy link and paste into web browser) i.imgur.com/kb8DT.png

Please help as I need to create, and access a Toggle Switch created in the .plist file. I am new to iPhone Programming.

Here's the code I'm using to set the user preference switch:

// Set the application defaults
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"YES" forKey:@"ShuffleToggleKey"];
[defaults registerDefaults:appDefaults];
[defaults synchronize];

And here's the code I'm using to get the state of the user preference switch:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
BOOL enabled = [defaults boolForKey:@"ShuffleToggleKey"];

Answers


It seems, that you're putting string object and trying to get boolean value. You should or get out the string like

NSString *enabledStr = [defaults stringForKey:@"ShuffleToggleKey"];
BOOL enabled = [enabledStr boolValue];

or put a boolean value in the first place like that:

  [defaults setBool:YES forKey:@"ShuffleToggleKey"];

Then you can retrieve it as

BOOL enabled = [defaults boolForKey:@"ShuffleToggleKey"];

Need Your Help

Prevent duplicate employee ids in registration SQL Database

asp.net sql-server stored-procedures

I created a simple asp.net form which allow users to view a list of dates for a training and register for that date , they enter their name and employeeid manually ( i dont want to allow dulpicate

Direct a URL directly to a GlassFish application in a virtual server

dns glassfish hosting virtual-server

We have a domain name with DNS management facility. We also have a web application developed in a GlassFish server hosted in a virtual server with a path is

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.