Then either use
InputStream is = getResources().openRawResource(R.raw.YourPlistFile);
or
InputStream is = context.getAssets().open("YourPlistFile?.plist");
and then
NSDictionary rootDict = (NSDictionary)PropertyListParser.parse(is);
Regards,
Daniel
An 04.03.2014 21:21:25, vampke <rescomw...@gmail.com>geschrieben:
--
You received this message because you are subscribed to the Google Groups "plist-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plist-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi,just get an InputStream for your resource. For that it should be located in the res/raw/ folder.Then either use
InputStream is = getResources().openRawResource(R.raw.YourPlistFile);
or
InputStream is = context.getAssets().open("YourPlistFile?.plist");
and then
NSDictionary rootDict = (NSDictionary)PropertyListParser.parse(is);
Yeah, i was wondering about that strange error, please just use the java.io.InputStream class. Parsing should work fine now.
Regards,
Daniek
--
NSDictionary rootDict = null;The reason seems to be in the fact that my plist file (which works fine in ios) is an array of dictionnaries:
try {
rootDict = (NSDictionary)PropertyListParser.parse(inputStream);
} catch (Exception e) {
e.printStackTrace();
}
<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
...key-string pairs
</dict>
<dict>
...
</array>
</plist>
InputStream inputStream = getResources().openRawResource(resourceId);
NSArray rootArray = null;
try {
rootArray = (NSArray) PropertyListParser.parse(inputStream);
} catch (Exception e) {
e.printStackTrace();
}
NSObject[] my_object = rootArray.getArray();
for(NSObject param:my_object) {
NSDictionary title = (NSDictionary) param;
etc...