Dissecting SemanticMerge, Part 2: Enter MonoMac

Wednesday, March 19, 2014 0 Comments

Note: this is the second part in the Dissecting SemanticMerge series. Part I is How we develop for Mac using C# and MonoMac.

So, if you’re going to write a C# “native looking” app for Mac the choice is MonoMac a.k.a. Xamarin.Mac. It is pretty well documented and it looks solid.

The first thing you’ll have to do is to go and grab a Xamarin Studio installer and you can play with it for free before you decide to go commercial.

Installing is easy and then you’ll be on a very familiar environment since it feels like Visual Studio (it is the famous MonoDevelop now in Xamarin disguise, pretty polished. We’ve been using it for months and it is pretty good. Of course, MonoDevelop 4 is also solid on Linux. Having used all versions since their first release, version 4 is really a plus).

The .xib files and the Interface Builder

I strongly recommend that you go and complete one of the basic Xamarin.Mac tutorials. You’ll start getting familiar with objects starting with NS (NSApplicationDelegate, NSObject and many more) and then with the Interface Builder.

The Interface Builder is the Xcode (the native Mac IDE to develop Objective-C, developed by Apple) interface to design user interfaces.

Interface Builder is the typical interface designer, similar to what you’d expect as a WinForms or WPF developer.

You can go and drag a button (a “Push Button” in Mac jargon) to the window area and you have created your first button. You can edit its properties and change the title:

Then you can drag the button to the MainWindowController.h to create an outlet or an action. This is the way in which the code will discover the button (or any other control) you have just created.

Once you’re done with this, you’ll be able to add an event to your code as follows:

Just notice I’m overriding the AwakeFromNib method which is like the “Load” method in WinForms applications. It is invoked just when the window is activated.

You can learn more about this following the Xamarin tutorials, so I’ll just continue focusing on what’s not in the tutorials :-)

We develop Plastic SCM, a version control that excels in branching and merging, can deal with huge projects and big binary assets natively, and it comes with GUIs and tools to make everything simpler.

If you want to give it a try, download it from here.

We are also the developers of SemanticMerge, and the gmaster Git client.

0 comments: