[Pythonmac-SIG] Categories and runtime functions (original) (raw)
Ronald Oussoren ronaldoussoren at mac.com
Wed Nov 24 07:31:52 CET 2004
- Previous message: [Pythonmac-SIG] Categories and runtime functions
- Next message: [Pythonmac-SIG] Categories and runtime functions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 23-nov-04, at 22:34, Dethe Elza wrote:
Can PyObjC be used to extend existing Objective-C classes, either via Categories or classaddMethods() (or in any other way)? What are the requirements to do so? For instance, I believe Categories require the headers to be available.
See the documentation for objc.classAddMethods:
classAddMethods(targetClass, methodsArray)
Adds methods in methodsArray to class. The effect is similar to how
categories work. If class already implements a method as defined in
methodsArray, the original implementation will be replaced by the
implementation from methodsArray.
In the unreleased SVN version you can also use objc.Category:
class NSObject (objc.Category(NSObject)):
def myMethod(self):
pass
objc.Category is syntactic suguar for objc.classAddMethods.
Ronald
--Dethe "And you think you're so clever and classless and free" — John Lennon on prototype-based programming_______________________ Pythonmac-SIG maillist - Pythonmac-SIG at python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
X|support bv http://www.xsupport.nl/ T: +31 610271479 F: +31 204416173
- Previous message: [Pythonmac-SIG] Categories and runtime functions
- Next message: [Pythonmac-SIG] Categories and runtime functions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]