Xamarin.iOS, convert Dictionary to NSDictionary

后端 未结 2 1329
梦如初夏
梦如初夏 2021-02-20 07:42

Am trying to integrate Branch.io in my Xamarin project and came across this requirement to convert c#\'s Dictionary to NSDictionary.

Tried

  • dictionary as N
2条回答
  •  暖寄归人
    2021-02-20 08:01

    This is how i converted a dictionary to an NSDictionary

    var iconattrs = new Dictionary
                    {
                        {"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())
    

提交回复
热议问题