Am trying to integrate Branch.io in my Xamarin project and came across this requirement to convert c#'s Dictionary to NSDictionary.
Tried
Tried this as well
private NSMutableDictionary BranchData (Dictionary<string, object> data)
{
List<string> keys = data.Keys.ToList();
NSMutableDictionary branchData = new NSMutableDictionary ();
foreach (string key in keys) {
branchData.Add (new NSString(key), data[key] as NSObject);
}
return branchData;
}
Didn't work.
Any leads would be helpful. Thanks!
UPDATE:
https://stackoverflow.com/a/5664785/344798
This is how i converted a dictionary to an NSDictionary
var iconattrs = new Dictionary<string, string>
{
{"ITEMTYPE", "DIVESITE"},
{"LOCATION", diveSite.Location},
{"DESCRIPTION", diveSite.BriefDescription},
{"LINK", diveSite.Link},
{"ID", diveSite.ID.ToString()}
};
var myResult = NSDictionary.FromObjectsAndKeys(iconattrs.Values.ToArray()
,iconattrs.Keys.ToArray())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With