[Mono-osx] how override an Objective C method?

Geoff Norton gnorton at novell.com
Wed Oct 27 14:23:22 EDT 2010


Hello,
 
> My best guess is this, but the app crashes inside the call to the base method.
> 
>         [Export("respondsToSelector:")]
>         public override bool RespondsToSelector (Selector sel)
>         {
>                 bool result = base.RespondsToSelector(sel);
>                 return result;
>         }

As miguel said, you're wanting to bind a static method so you need something
like this:

[Export ("respondsToSelector:")]
public static bool RespondsToSelector (Selector sel)
{
/* put your custom logic here since you're overriding a static I presume you
have some */
bool result = Messaging.bool_objc_msgSend (Class.GetHandle
("WhateverYourSuperClassIs"), Selector.GetHandle ("respondsToSelector:"));
return result;
}

The bigger question is why do you want to override this method?  It's very
odd that you would want to do this, since the NSObject instance and
objc-runtime should handle this for you.

-g



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20101027/d1caa977/attachment.html 


More information about the Mono-osx mailing list