Reputation: 20289
I'm seeking for a solution in C#
. I have a dictionary like
NSDictionary metrics = new NSDictionary ("leftInset", 22);
Now I want to get the number as float
. I tried this
metrics.ValueForKey(new NSString("leftInset"))
but the return value is of type NSObject
. How can I get the float?
Upvotes: 3
Views: 3724
Reputation: 241
Cast it to an NSNumber.
There is a convenient constructor that takes at least one key and one value, with optional values that will create the dictionary by pairing each key with a value. If you use .NET objects, the keys and values will first be boxed into NSObjects using NSObject.FromObject.
Upvotes: 3