On Oct 8, 2012, at 4:05 AM, Jon Hodgson < email@hidden> wrote: NSBundle* viewBundle = [NSBundle bundleWithPath: [unescapedPath autorelease]]; BOOL loaded = [viewBundle load]; // I put this in to check the bundle was being found Class viewClass = [viewBundle classNamed: viewClassName];
Anyway, with the Juce bundle, it finds the viewClass, with mine it doesn't, and I can't work out why not. Are the class names different? Are you sure your class name is unique?
The Objective-C runtime has a single flat per-process namespace for classes. That is, class names aren’t scoped to anything like a bundle. You can think of there being a global dictionary that maps class names to implementations. If a loaded bundle or framework contains a class Foo, that class will be available anywhere in the process by calling something like NSClassFromString(@“Foo”). A corollary of this is that you can only have one implementation of a class of the same name loaded at once. If there are ever two definitions of a class of the same name loaded, the runtime will print a warning, and which class actually gets used is undefined.
I don’t know what the exact behavior is of -[NSBundle classNamed:] because I’ve never had to use it — it isn’t necessary to ask a bundle for a class, you can just as the runtime via NSClassFromString, once the bundle is loaded.
Hope this sheds some light on your problem...
—Jens |