Re: Permissions problem after NSTask application launch
Re: Permissions problem after NSTask application launch
- Subject: Re: Permissions problem after NSTask application launch
- From: David Darby <email@hidden>
- Date: Tue, 19 Apr 2005 09:24:35 +1000
Dear Sherm
Thanks a lot! Your intuition was correct. It was due to a "File not
found" error, not permissions. By adding:
[task setCurrentDirectory:path];
the directories are found correctly.
The full working code is now:
- (void)awakeFromNib
{
[self launchStudentVersion];
}
- (void)launchStudentVersion
{
NSTask* task = [[NSTask alloc] init];
NSMutableArray* args = [NSMutableArray array];
NSBundle* appBundle = [NSBundle mainBundle];
// set arguments
NSString* firstCmd;
NSString* cmd1 = @"/MyApp.app/Contents/MacOS/MyApp";
NSString* cmd2 = @"-student";
NSString* path = [[appBundle bundlePath]
stringByDeletingLastPathComponent];
// set working directory to application's directory
[task setCurrentDirectory:path];
firstCmd = [path stringByAppendingString:cmd1];
[task setLaunchPath:firstCmd];
[args addObject:firstCmd];
[args addObject:cmd2];
[task setArguments:args];
[task launch];
[NSApp terminate:self];
}
Thanks for your assistance.
David Darby
Em email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden