views:

873

answers:

1

Hello ! Every one here.

I am facing a problem in accessing Settings.bundle.

Let me explain what exactly I am doing.

  1. Any kind of new Project Template from File ( Under iPhone OS ) - preferable View based.
  2. Now Right click on your project / Resources group.
  3. Select Add / New File
  4. Under iPhone Os - resource - Settings Bundle.
  5. Name it as strictly "Settings.bundle"

Now The very important steps.

  1. Expand Settings.bundle in your project.
  2. Click on Root.plist
  3. In Editor - Expand Preference Specifiers
  4. Remove Item 2, Item 3, Item 4
  5. Select Item 1 & copy & Past it.
  6. Edit Item 2' type ( Item 1's copy )
  7. Set PSChildPaneSpecifier as type ( of item'2 )
  8. Set Title as you wish.
  9. Add a new Key value pair to this ( item 2 ) dictionary.
  10. Set Key = "File" & String = "FontSettings"

Now In above steps, I have specified " I need a child pane for settings " & Child Pane settings will be loaded from FontSettings.plist

Ok. Further Steps.

  1. Now, Right click on your Settings.bundle / en.lproj ( Just because we need to add another plist file under settings.bundle.
  2. Add / New File - Under Mac OS x - Choose Other -> Property List
  3. Name as FontSettings.plist

For just verification that settings.bundle contains that file or not.

  1. Open your project in finder.
  2. Right click on Settings.bundle
  3. Click on show package contents.
  4. If it shows FontSettings.plist in package contents, Then it's perfect till now.

Now, For FontSettings.plist

  1. Open Root.plist under settings.bundle.
  2. Copy Stringtable, PreferenceSpecifiers to the FontSettings.plist
  3. Now in FontSettings.plist - Add settings as you wish.

Check in simulator.

  1. Run program & tap on button. ( To terminate app. )
  2. Go to settings.
  3. Open Your Project Settings
  4. You can go to child pane.

Till now, I believe I have followed the correct steps.

The problem that I am facing is here now.

If there is just a single Root.plist, we can directly access

[[NSUserDefaults standardUserDefaults] stringForKey:@"fName"]

Like above.

But the question is "How to access - child pane settings ? "

I have tried following way

NSString *str=[[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
NSString *path=[str stringByAppendingPathComponent:@"FontSettings.plist"];
NSDictionary *dFor=[NSDictionary dictionaryWithContentsOfFile:path];

But the problem in above code is "It's just giving me the same default value every time, even after - changing the values from settings of iPhone - settings.

What should I do for Accessing Child.plist settings? ( that user has set )

Thanks in advance for sharing your knowledge.

Sagar.

+2  A: 

You access child pane settings exactly like the root settings. There's no difference between hierarchies in accessing the user defaults.

For instance, if a PSToggleSwitchSpecifier in FontSettings.plist has Key being isBold, then you'll access this setting with

[[NSUserDefaults standardUserDefaults] boolForKey:@"isBold"]
KennyTM
I placed this question on 23rd Feb. But no one answered. The answer was very simple for who knows.
sugar