I want to load NSDictionary from the following plist file, without changing the order of it.
This plist file is Here.
I have researched many things, and I found OrderedDictionary and M13OrderedDictionary.
First, I tried NSDictionary (I know it fails)
- (void)testNSDictionary {
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:filePath];
NSLog(@"%@",dictionary);
}
Then I got the following log:
{
G = {
R = {
H = "";
S = "";
};
V = {
T = "";
};
};
S = {
B = {
L = "";
};
O = {
K = "";
L = "";
};
V = {
T = "";
};
};
}
This is completely different order from the original plist file! (I know)
I think this is alphabetical order.
Next, I tried OrderedDictionary with the following code:
#import "OrderedDictionary.h"
- (void)testOrderedDictionary {
OrderedDictionary *dictionary = [OrderedDictionary dictionaryWithContentsOfFile:filePath];
NSLog(@"%@",dictionary);
}
Then I got the following log:
{
G = {
R = {
H = "";
S = "";
};
V = {
T = "";
};
};
S = {
B = {
L = "";
};
O = {
K = "";
L = "";
};
V = {
T = "";
};
};
}
Huh? This is the same result as NSDictionary.
Finally, I tried M13OrderedDictionary with the following code.
#import "M13OrderedDictionary.h"
- (void)testM13OrderedDictionary {
M13OrderedDictionary *dictionary = [M13OrderedDictionary orderedDictionaryWithContentsOfFile:filePath];
NSLog(@"%@",dictionary);
}
Then I got the following log:
{
}
Nothing returned. I don't understand what is going on.
I would like to know how I can correctly use OrderedDictionary and M13OrderedDictionary. If they are outdated, I want to know the alternative way to parse plist file into NSDictionary or NSArray or something.
Note: I don't want to change plist file, because this format is the best for me.
I found that the script above has some bugs.
I contacted with the developer of OrderedDictionary and finally he made the importing and exporting function.
OrderedDictionary v1.4 can import OrderedDictionary data from plist file(xml format only).
I really appreciate it.