If the extra cocoa app is a resource in your main bundle, then it should be in 
Contents/Resources, not Contents/MacOS.  If you put it in Contents/Resources, 
then you can retrieve it easily via:

NSString * linrgPath = [[NSBundle mainBundle] pathForResource:@"linrg2" 
ofType:@""];

The name "pathForResource" means that it's supposed to be finding the requested 
resource in the Resources folder (hence path for "Resource").

If for some strange reason it *must* be in the same directory as the current 
executable, then I would recommend using the executable path to find it:

NSString * linrgPath = [[[[NSBundle mainBundle] executablePath] 
stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"linrg2"];

HTH,

Dave

On Feb 24, 2010, at 1:30 PM, McLaughlin, Michael P. wrote:

> This is just a minor glitch but I hate loose ends.
> 
> I have a Cocoa app as a resource in my MainBundle.  If I try to get its
> executable via the obvious
> 
> NSString * linrgPath = [myBundle pathForResource:
> @"linrg2.app/Contents/MacOS/linrg2" ofType: @""];
> 
> then linrgPath is nil;
> 
> However, if I split the path into two pieces it works as intended.
> 
> NSString * linrgPath = [myBundle pathForResource: @"linrg2.app" ofType:
> @""];
> linrgPath = [linrgPath stringByAppendingString:@"/Contents/MacOS/linrg2"];
> 
> Is this reasonable?
> 
> FWIW, the full path expands to 104 chars and contains one space.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to