This tutorial will guide you through the process of migrating from the Monobjc bridge 2.x series to Monobjc bridge 3.x series:

  • Class Export
  • Dealloc Pattern
  • Disposable Pattern
  • API Deprecation
  • API Changes

Class Export

With the new major release, there was some light changes in the way .NET classes are exposed. If you need to make an instance variable visible to the Objective-C runtime, the attribute to use is now different:

In the Monobjc bridge 2.x series, exposing an instance variable was done like this:

[ObjectiveCField]
public NSButton helloButton;

[ObjectiveCField]
public NSMatrix messageRadio;

[ObjectiveCField]
public NSPopUpButton objectPopUp;

In the Monobjc bridge 3.x series, exposing an instance variable is now done like this:

[ObjectiveCIVar("helloButton")]
public virtual NSButton helloButton
{
    get { return this.GetInstanceVariable ("helloButton"); }
    set { this.SetInstanceVariable ("helloButton", value); }
}

[ObjectiveCIVar("messageRadio")]
public virtual NSMatrix messageRadio
{
    get { return this.GetInstanceVariable ("messageRadio"); }
    set { this.SetInstanceVariable ("messageRadio", value); }
}

[ObjectiveCIVar("objectPopUp")]
public virtual NSPopUpButton objectPopUp
{
    get { return this.GetInstanceVariable ("objectPopUp"); }
    set { this.SetInstanceVariable ("objectPopUp", value); }
}

If you are using an IDE to develop, here are the Search/Replace regular expression to use to make the replacement:

Search:

\[ObjectiveCField\][\n\w\s]+public\s+([A-z0-9]+)\s+([_A-z0-9]+);

Replace with:

[ObjectiveCIVar] public $1 $2 { get { return this.GetInstanceVariable<$1>("$2"); } set { this.SetInstanceVariable("$2", value); } }

Dealloc Pattern

In the Monobjc bridge 3.x series, the fields synchronization is not needed anymore when exposing a method. You can safely remove the SynchronizeFields property from the ObjectiveCMessage attributes.

In the Monobjc bridge 2.x series, dealloc pattern was done like this:

[ObjectiveCMessage("dealloc", SynchronizeFields = false)]
public void Dealloc()
{
    // ...
    this.SendMessageSuper(MyRecorderControllerClass, "dealloc");
}

In the Monobjc bridge 3.x series, dealloc pattern is now done like this:

[ObjectiveCMessage("dealloc")]
public void Dealloc()
{
    // ...
    this.SendMessageSuper(MyRecorderControllerClass, "dealloc");
}

Disposable Pattern

In the Monobjc bridge 3.x series, the IDisposable pattern is more strictly enforced.

API Deprecation

In the Monobjc bridge 3.x series, OS X 10.3 is no longer supported.

API Changes

In the Monobjc bridge 3.x series, OS X 10.3 is no longer supported.

In the Monobjc bridge 3.x series, Foundation and AppKit frameworks have been splitted.

The following enumerations have been renamed:

  • NSResizingFlags has been renamed to NSAutoresizingMask