im making an osx application which has a button that sets the user's background as their screensaver. here's my code:
-(IBAction)startSaver:(id)sender {
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/open"];
NSArray *arguments;
arguments = [NSArray arrayWithObjects: @"-a", (@"/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background"), nil];
[task setArguments: arguments];
[task launch];
}
for some reason i keep getting this error:
FSPathMakeRef(/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background) failed with error -43.
please help!!
fnfErr -43 File or directory not found; incomplete pathname.
/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background
path doest exist.
you can also use system command:
system("/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background");
using NSTask:
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine"];
NSArray *arguments;
arguments = [NSArray arrayWithObject:@"-background"];
[task setArguments: arguments];
[task launch];