Re: [Pyobjc-dev] Categories (was: Subclassing NSTextField)
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2002-12-18 06:33:31
|
On Tuesday, Dec 17, 2002, at 21:08 Europe/Amsterdam, bb...@ma... wrote: > On Tuesday, Dec 17, 2002, at 14:25 US/Eastern, Steven D. Arnold wrote: > >> On a related note, is there any mechanism to implement categories in >> pyobjc? >> I thought this question had been asked before, but I couldn't find it >> in my >> archive. > > Good question: Ronald? Not really. You can of course implemenent methods from a category for your own subclasses (e.g. like the text* categories Bill mentioned in the previous message), but you cannot add new methods to existing Objective-C classes. You can add new methods to subclasses defined in Python. Some other useful things you cannot do at the moment (using the Internet as my Todo list :-) are: - Adding new methods to subclassses implemented in Python if those methods override/extend existing methods. You can do this, but your method won't be called if someone tries to access this method from Objective-C. - Removing methods from subclasses implemented in Python, if those methods override/extend existing methods. Again you can actually do this, but this doesn't have the right semantics. - Redefine an existing class. This is a feature: Because Objective-C has a flat namespace and python doesn't you might otherwise accidently replace and existing class. It is also not really possible to implement this without memory leaks. All of these would be usefull for incremental development and may be added in some future version (that includes support for categories). Ronald |