Hi, >From what I understand you want to replace the implementation of a method without deriving from the corresponding class.
It is possible to do, but it's not easy. What you need to do is to manually replace the method implementation of the class using objective-c runtime functions (which are described here: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html ) In pseudo code it would be something like this: static extern IntPtr class_getInstanceMethod (IntPtr, IntPtr); static extern IntPtr method_setImplementation (IntPtr, IntPtr); delegate void DrawDelegate (IntPtr @this, IntPtr selector, <additional draw() parameters>); [MonoPInvokeCallback (typeof (DrawDelegate))] static void Draw (IntPtr @this, IntPtr selector, <additional draw() parameters>) { // the two first arguments are required, that's how objc method invocation works. NavigationBar nav_bar = new NavigationBar (@this); // do your custom drawing here nav_bar.Dispose (); } static DrawDelegate DrawImplementation = Draw; void ReplaceDraw () { IntPtr nav_bar_class = new Class (typeof (NavigationBar)).Handle; IntPtr method = class_getInstanceMethod (nav_bar_class, new Selector ("draw:").Handle); IntPtr new_impl = Marshal.GetFunctionPointerForDelegate (DrawImplementation); method_setImplementation (method, new_impl); } I hope this helps (but I recommend you find another way of doing it :) Rolf On Thu, Apr 19, 2012 at 4:42 AM, dermotos <[email protected]> wrote: > Thanks for the replies, you have more or less come to the same conclusions > I > have regarding extension methods etc... > The partial class approach wont work as the original class also needs to be > marked as partial. Also, partial is just a compiler convenience, that joins > two .cs files together before compilation, so wont work with any > pre-compiled framework code. > > I've decided I will be using a "pretty enough" approach for ios4 users. Its > too much extra work for a constantly shrinking user base. If they're too > lazy to plug their phone into iTunes once a year, then they cant have nice > things. :-) > > -- > View this message in context: > http://monotouch.2284126.n4.nabble.com/Obj-C-Categories-in-Monotouch-tp4567460p4569728.html > Sent from the MonoTouch mailing list archive at Nabble.com. > _______________________________________________ > MonoTouch mailing list > [email protected] > http://lists.ximian.com/mailman/listinfo/monotouch >
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
