[OGo-Developer] Significance of PRINCIPAL_CLASS

Helge Hess developer@opengroupware.org
Tue, 23 Oct 2007 01:48:15 +0200


On 23.10.2007, at 01:11, Adam Tauno Williams wrote:
> What is the significance of the "PRINCIPAL_CLASS" in the context of
> something like a ZideStore bundle?

Every bundle has a principal class which can be accessed by code  
loading the bundle using [NSBundle principalClass].
SOPE extends this a bit with NGBundleManager.

> In all the bundles in the tree the PRINCIPLE_CLASS seems to just  
> descend from NSObject and implement nothing.

Yes, they usually do little (though AFAIK there are some exceptions  
in OGo). They are just some kind of entry point.

> I've create a "Hello World" ZideStore bundle for the sake of some
> documentation,  and I can set the PRINCIPLE_CLASS to a NSObject  
> child or
> to the object that actually does the work,  it doesn't seem to have  
> any
> affect.

Si. But usually its best to set it to a class which is actually  
contained in (compiled into) the bundle so that the reverse mapping  
works properly. This might be relevant for some code.

> I've overloaded init and specified a logWithMessage,  and I never see
> the message.  Is this class even instantiated?

Not necessarily, no. Well, of course the *class object* is  
instantiated (you could check by implementing +load). Remember that a  
class is full object in ObjC (so serves as some kind of singleton).

Though NGBundleManager can instantiate "bundle handlers". Don't  
remember the details though (I think you need to specify that in the  
bundle-info.plist).

Greets,
   Helge
-- 
Helge Hess
http://www.helgehess.eu/