The "principal class" of a bundle is merely the Objective-C class that is marked as the primary class of the bundle and, thusly, will be returned by the -principalClass method of the bundle instance Nothing more, nothing less and there is no magic It only exists for loadable bundles because only loadable bundles define new Objective-C classes.
The "principal class" of a bundle is merely the Objective-C class that is marked as the primary class of the bundle and, thusly, will be returned by the -principalClass method of the bundle instance. Nothing more, nothing less and there is no magic. It only exists for loadable bundles because only loadable bundles define new Objective-C classes.
Thanku.. can you give me links for any opensource project which has used principalClass in it. – suse Dec 29 '09 at 5:13.
The principalClass allows you to know what class to start using once you have loaded a bundle. For example, say you are using bundles to represent plugins for an image processing app. When you tell the Objective-C runtime to load the bundle "CSISharpener.
Bundle", it will load a bunch of new classes into memory. However, you still need to know the name of the class to send messages to in order to actually use the plugin. In our example, principalClass might return CSISharpeningFilter, which is conforms to the plugin protocol we told the plugin developers to use.So we can create an instance of "principalClass" and start using it, without knowing ahead of time what the class name is.
In other words, principalClass is there to allow the programs that load bundles and easy way to find an "entry point" into the code they have just loaded. Exactly what it is used for is going to depend on what code is loading the bundle and what it is using it for.
I will give you an example of how you can create and load a bundle as plugin. Hope that this will help you a lot. I must say that I agree with the other 2 (so far) answers.So... Create an Xcode project as "Bundle" (in Xcode 3.2.6 is in New Project->Framework & Library-> select "Bundle").
Create the following files... PClass. H #import @interface PClass : NSObject { } - (NSString*) stringMessage; @end PClass. M - (NSString*) stringMessage { return @"Hallo from plugin"; } in the projects .
Plist file add the following two entries: "Bundle display name" "MyPlugin" "Principal class" "PClass" Then compile the project and move the binary (.../build/Debug/yourPlugin. Bundle) to a folder you like to keep your plugins of a project of yours (may be copied into aProject. App/Plugins/ with a little extra care).
Then to an already Xcode project add the following: - (void) loadPlugin { id bundle = NSBundle bundleWithPath:@"the path you/placed/yourPlugin. Bundle"; NSLog(@"%@", bundle infoDictionary valueForKey:@"CFBundleDisplayName"); // Here you can preview your plugins names without loading them if you don't need to or just to // display it to GUI, etc NSError *err; if(!bundle loadAndReturnError:&err) { // err } else { // bundle loaded Class PluginClass = bundle principalClass; // here is where you need your principal class! // OR... //Class someClass = bundle classNamed:@"KillerAppController"; id instance = PluginClass alloc init; NSLog(@"%@", instance stringMessage); instance release; // If required bundle unload; // If required } } You have just loaded a bundle via its Principal Class as a plugin of an application.
The principalClass allows you to know what class to start using once you have loaded a bundle. For example, say you are using bundles to represent plugins for an image processing app. When you tell the Objective-C runtime to load the bundle "CSISharpener.
Bundle", it will load a bunch of new classes into memory. However, you still need to know the name of the class to send messages to in order to actually use the plugin. In our example, principalClass might return CSISharpeningFilter, which is conforms to the plugin protocol we told the plugin developers to use.
So we can create an instance of "principalClass" and start using it, without knowing ahead of time what the class name is. In other words, principalClass is there to allow the programs that load bundles and easy way to find an "entry point" into the code they have just loaded. Exactly what it is used for is going to depend on what code is loading the bundle and what it is using it for.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.