Re: [Pyobjc-dev] NIB Validation & action methods
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2002-11-17 07:07:09
|
On Saturday, Nov 16, 2002, at 23:34 Europe/Amsterdam, Just van Rossum wrote: > bb...@ma... wrote: > >>> Erm, when is this warning emitted? When the class is instantiated >>> or when the button is clicked? If the latter: NibLoader could do it >>> at class-build-time. >> >> Neither; when the NIB is loaded and the nib loading mechanism walks >> through the connections to ensure that the appropriate target/action >> methods can be connected. > > You mean when (eg.) a window is instantiated? That is what I understood of it. This would only catch errors for actions that are actually used, not for actions that are defined but are not a target. I prefer emitting warnings when the class is instantiated as this would give you a complete set of warnings during program startup. Actually only if you load all Nib classes during program startup but I've been doing that upto now. > >> This is the only time that such validation can occur. Class >> instantiation is too early as there may be additional methods added >> to the class between the time the class is created and those methods >> may contain the action implementations. > > Not sure if I get this. What NibLoader could do is, that as soon the > module > containing the class is imported, it verifies the action methods > contained in > the class body actually contain all the methods as specified in the > nib. How > does this compare to what the Cocoa runtime does? In Objective-C it is possible to define categories that in effect add new methods to an existing class interface. It is possible to load categories at runtime (NSString is one example in Cocoa, its interface is defined in Foundation and then enhanced in AppKit). In Python you can also add new methods to a class. I'd not worry to much about this, if only because it will be less efficient to call those additional methods from Objective-C: The additional methods are called through an NSInvocation while the normal methods are called through more efficient method stubs. Ronald |