- Home /
Add array to plist post process
So I can add key/value in the plist using the PlistElementDict object but I can't see how to add an array.
I can create the array but there is no SetArray method (which would sound appropriate next to other SetXXXX methods).
Here is how far I got:
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
PlistElementDict rootDict = plist.root;
key = "MyKey";
rootDict.CreateArray(key);
PlistElementArray array = new PlistElementArray();
array.AddString("ValueA");
array.AddString("ValueB);
Now I would expect a method to add the array to the rootDict object but I can't figure out how it is meant to happen.
Any insight?
Answer by fafase · Aug 24, 2015 at 12:27 PM
Well it was actually simple. The documentation could include a bit more details on that.
rootDict.CreateArray(key);
this returns the array object
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
PlistElementDict rootDict = plist.root;
key = "MyKey";
PlistElementArray array = rootDict.CreateArray(key);
array.AddString("ValueA");
array.AddString("ValueB);
Now array points to the array object newly created and item can be added to it.
Is there a way to add an array/dictionary to an existing key?
I can't seem to find a way to do this.
Also, have you found a way to add an Array inside an Array?
Anyone can help me? I trying but can't make it work, I need to add this to the plist:
CFBundleURLTypes array dict key CFBundleURLName string>com.app key>CFBundleURLSchemes array> string>app /array> /dict> /array>
Cheers!
Your answer
Follow this Question
Related Questions
PostProcessBuild files fail 2 Answers
PlayerPreffs can :S 2 Answers
How to remove 3GS device from supported devices? 1 Answer
custom .plist file not added to ios project 3 Answers
Resources.Load how to add more supported file types 0 Answers