Re: [Pyobjc-dev] Categories (was: Subclassing NSTextField)
Brought to you by:
ronaldoussoren
From: <bb...@ma...> - 2002-12-18 15:51:27
|
On Wednesday, Dec 18, 2002, at 10:44 US/Eastern, Peter Montagner wrote: > I don't know if this is what you want but it may help: > > http://www.cocoadev.com/index.pl?MethodSwizzling Personally, I'm intimately familiar with method swizzling-- having used it many times to wreak havoc upon an application. :-) His example isn't very good -- he could have used Posing to achieve the same thing. The code is fairly clean, but has some issues. There is no need to swizzle the types-- the types should not change without serious risk of crashing. There is no need to actually declare a method. His alt method could easily have been declared as a C function: void alt_method(T *self, SEL _cmd) { ... } This allows one to define the method without knowing the class declaration in the first place-- which is where swizzling is most useful (i.e. editing classes for which you do not have a declaration that can be used to compile against). b.bum |