[Mono-osx] Working with delegates

Miguel de Icaza miguel at novell.com
Tue Nov 30 11:39:57 EST 2010


>
> Thanks for your hints. So this is basically the way you choose when it
> comes to implementing NSTableView data sources as well, right?
>
> Just for the background: Is there nothing like the concept of protocols on
> the .NET-side?
>

There is nothing in C# or in the ECMA CLI that supports that model.

You can still support any protocol by hand by using attributes (like:
[Export ("someSelector:Named:")]) but there is no language support other
than that.   The downside of using the loosely typed approach with manually
adding attributes is that if your attribute name is wrong, or if the
parameters that you declare are wrong, you will get the wrong results, or
even a crash.

To solve that problem, we introduced a strongly typed system that map
protocols to classes or abstract classes.   These classes have been
decorated with a special [Model] attribute that ensures that only
overwritten methods ever get invoked and only overwritten methods ever
return true to the Objective-C messages
"does-this-object-respond-to-this-selector" -- the foundation for optional
methods in protocols.

The Model attribute allows developers to use strong types, override methods
strongly and not have to worry about incorrect signatures or incorrect type
definitions.   The responsibility is shifted from the developer to MonoMac.

Miguel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20101130/8c805f10/attachment.html 


More information about the Mono-osx mailing list