Bundles work differently depending on application launch path?
Bundles work differently depending on application launch path?
- Subject: Bundles work differently depending on application launch path?
- From: Stuart Halloway <email@hidden>
- Date: Fri, 16 Jan 2004 09:07:39 -0500
[NSBundle mainBundle] works to load classes from the mainBundle if you
launch a console application from the current directory. However, if
you launch from some other directory, specifying a relative path to the
application, you can no longer use [NSBundle mainBundle] to load
classes.
The output from the method below is instructive. [NSBundle mainBundle]
and [NSBundle bundleForClass:[self class]] return the same object if
you launch from the application directory, but different objects if you
launch using a relative path.
Any ideas for a workaround to get mainBundle working again?
Stu
- (void) testBundles {
NSArray* bundles = [NSBundle allBundles];
NSEnumerator* en = [bundles objectEnumerator];
NSBundle* bundle;
while (bundle= [en nextObject]) {
NSLog(@"Bundle %X has path %@ xpath %@", (long) bundle, [bundle
bundlePath], [bundle executablePath]);
}
bundle = [NSBundle mainBundle];
NSLog(@"Main Bundle %X has path %@ xpath %@", (long) bundle, [bundle
bundlePath], [bundle executablePath]);
bundle = [NSBundle bundleForClass:[NSObject class]];
NSLog(@"NSObject Bundle %X has path %@ xpath %@", (long) bundle,
[bundle bundlePath], [bundle executablePath]);
bundle = [NSBundle bundleForClass:[self class]];
NSLog(@"Self Bundle %X has path %@ xpath %@", (long) bundle, [bundle
bundlePath], [bundle executablePath]);
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.