tags:

views:

12

answers:

1

Hello everyone

I use codes below to load plist file

    NSDictionary* tSetDict = [NSDictionary dictionaryWithContentsOfFile:plistPath];
NSArray* prefs = [tSetDict objectForKey:@"PreferenceSpecifiers"];

// Iterate through dictionaries to find required value
for (NSDictionary* setDict in prefs){

            //.........
    }
}

I hope to know setDict belongs to which group (section).

Is it possible?

Welcome any comment

Thanks

interdev

A: 

Not sure if I understand your question correctly but I will try anyways....

Use the simple/slow iteration:

for (int i=0;i < [prefs count];++i)
{
  NSDictionary *setDict = [prefs objectAtIndex:i];
  NSLog(@"got the dict from section %d", i);
}
Till
Thanks. I mean when iPhone app 'Setting' loads setting.bundle plist file. It will load the groups(PSGroupSpecifier) one by one(in each group there are elements PSToggleSwitchSpecifier, PSSliderSpecifier, PSTitleValueSpecifier, PSTextFieldSpecifier)
and app 'Settings' will display the groups in different sections of a UITableView.
Now, if I have got the element(PSToggleSwitchSpecifier, PSSliderSpecifier, PSTitleValueSpecifier, PSTextFieldSpecifier) how can I know it belongs to which group.
for example:PSTextFieldSpecifier
it has keys:Title, Key, DefaultValue, IsSecure, KeyboardType, AutocapitalizationType,AutocorrectionType. But there is no key to indicate the "Text Field Element"(Type:PSTextFieldSpecifier) belong to which group.
I found it look likes app "Settings" load a “Group Element”(type:PSGroupSpecifier) at first, then display all elements/items follow it in a same group until load the next “Group Element”(type:PSGroupSpecifier). The next “Group Element”(type:PSGroupSpecifier) and the elements follow it will display in the next group/section.
Sorry I got you wrong. For the future: use the comment section for shortly describing issues with the solution posted. If you need to rephrase or enhance your question, use the Edit-function of your original question.
Till