Edytuj

Udostępnij za pośrednictwem


DictionaryContainer Constructors

Definition

Overloads

DictionaryContainer()

When overridden, call the base-class constructor with a NSMutableDictionary.

DictionaryContainer(NSDictionary)

When overridden, call the base-class constructor, passing the dictionary.

DictionaryContainer()

When overridden, call the base-class constructor with a NSMutableDictionary.

protected DictionaryContainer ();

Remarks

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:

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);
        }
    }
}

Applies to

DictionaryContainer(NSDictionary)

When overridden, call the base-class constructor, passing the dictionary.

protected DictionaryContainer (Foundation.NSDictionary dictionary);
new Foundation.DictionaryContainer : Foundation.NSDictionary -> Foundation.DictionaryContainer

Parameters

dictionary
NSDictionary

The dictionary to be wrapped.

Remarks

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:

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);
        }
    }
}

Applies to