我有以下plist,我需要keyItem1
和keyItem2
将其分配给string[]
。我能够获取项目但无法将其分配给字符串数组。我正在使用Xamarin,但客观的C也会有所帮助。
代码
string settingsBundle = NSBundle.MainBundle.PathForResource ("MySettings.bundle/Root", @"plist");
NSDictionary dic = NSDictionary.FromFile (settingsBundle);
var contacts = dic.ObjectForKey (new NSString ("keyarray1"));
MySettings.plist
<?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">
<dict>
<key>keyarray1</key>
<array>
<string>keyitem1</string>
<string>keyitem2</string>
</array>
</dict>
</plist>