NSNotificationCenter problem

Bill Bumgarner bbum at mac.com
Mon Nov 5 23:45:56 PST 2007


On Nov 5, 2007, at 11:42 PM, Bill Bumgarner wrote:
> You can still swizzle methods, you just can't do it in the raw Obj-C  
> structures.   It is still considered naughty, but at least there is  
> API via which you can commit the naughtiness in a somewhat  
> predictable fashion (i.e. it'll do the right thing in terms of  
> threading & cache flushing, but you'll still be hosed if you put the  
> wrong IMP somewhere).
>
> Specifically:
>
> 	OBJC_EXPORT BOOL class_addMethod(Class cls, SEL name, IMP imp,  
> const char *types);
> 	OBJC_EXPORT IMP class_replaceMethod(Class cls, SEL name, IMP imp,  
> const char *types);

Dang it.  Hit deliver too soon.   The whole point was also to say that  
these APIs are available in the 32 bit -- the legacy ObjC -- runtime,  
too.   You can write one bit of code that'll behave the same in 32 bit  
and 64 bit.

Convenient and consistent, but it doesn't make it any more of a good  
idea to go and class_replaceMethod() on just any method of any class. ;)

b.bum


More information about the MacOSX-dev mailing list