Error Reporting Pattern in MonoMac

When writing code that reports errors to the user, usually when I get back an NSError result, I use the following code snippet to show it:

if (err != null){
   NSAlert.WithError (err).BeginSheet (Window, delegate {
       // Any needed cleanup code can go here,
       // it is invoked when the Sheet goes away.

The above creates an NSAlert object using the WithError factory method, and then invokes the BeginSheet method to present this modally to the user. Usually you can put any cleanup code in the body of the provided delegate.

Posted on 05 Dec 2010 by Miguel de Icaza
This is a personal web page. Things said here do not represent the position of my employer.