Foundation.DictionaryContainer Class
Convenience base class used by strongly-typed classes that wrap NSDictionary-based settings.

See Also: DictionaryContainer Members

Syntax

public abstract class DictionaryContainer

Remarks

Many iOS and OSX APIs accept configuration options as untyped NSDictionary values, or return untyped NSDictionary values. The C# bindings offer strong-typed versions of those dictionaries, which allow developers to get code completion while passing parameters, and to extract data from return values. The DicionaryContainer is an abstract base class that encapsulates the common code to wrap NSDictionaries like this

When creating a strongly typed wrapper for NSDictionary, subclass the DicionaryContainer and provide two constructors: one taking an NSDictionary (to create the wrapper) and one taking no arguments, which should call the base class with an NSMutableDictionary. Then use one of the various Get and Set methods exposed by this class to get and set values. This is how a sample class would work:

c# Example

public class MyProperties : DicionaryContainer {
    public MyProperties () : base (new NSMutableDictionary ())
    {
    }
    
    public MyProperties (NSDictionary dict) : base (dict)
    {
    }

    static NSString boolKey = new NSString ("SomeBoolKey");

    public bool MyBool {
        get {
            return GetInt32Value (boolKey);
        }
	set {
	    SetInt32Value (boolKey, value);
        }
    }
}
	

Requirements

Namespace: Foundation
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0