principle classes from two bundles get confused
principle classes from two bundles get confused
- Subject: principle classes from two bundles get confused
- From: Shai Shasag <email@hidden>
- Date: Sun, 8 Nov 2009 15:47:33 +0200
The following code loads two different bundles and gets their
principle classes.
NSString* path_A = @"/My/Bundles/Folder/A.bundle";
NSBundle* bundle_A = [NSBundle bundleWithPath: path_A];
Class class_A = [bundle_A principalClass];
NSString* path_B = @"/My/Bundles/Folder/B.bundle";
NSBundle* bundle_B = [NSBundle bundleWithPath: path_B];
Class class_B = [bundle_B principalClass];
NSBundle* bundleFromClass_B = [NSBundle bundleForClass: class_B];
if (! [bundle_B isEqual: bundleFromClass_B])
{
NSLog(@"bundle_B is not equal to bundleFromClass_B");
}
if ([bundle_A isEqual: bundleFromClass_B])
{
NSLog(@"bundle_A is equal to bundleFromClass_B");
}
Unexpectedly This code produces the messages:
bundle_B is not equal to bundleFromClass_B
bundle_A is equal to bundleFromClass_B
How could this be? I think the problem is that both bundle_A &
bundle_B have principle class with the same name. Somehow Cocoa gets
confused.
Why would two different bundles have principle classes with the same
name you might ask?
Well actually there are more than a hundred such bundles in my
project. Each bundle is a plugin that follows the same API. If I was
to write a different principle class for each it would be a nightmare
to maintain.
Is there a way to tell Cocoa to use the class from each bundle
regardless that they both have the same name?
Thanks,
Shai
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden