set file's icon in a command line utility not working
- by Ief2
I just began to work with Objective-C and I'm managing pretty well. My last challenge was to make a command line utility, which I could than use in AppleScript. But my code does not work, not in the terminal, not in the AppleScript. So I'm asking you, what's the error in this peace of code, that should be very plain and easy?
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// -imagePath
// -filePath
NSUserDefaults *args = [NSUserDefaults standardUserDefaults];
NSString *soundPath = [args stringForKey:@"imagePath"];
NSString *filePath = [args stringForKey:@"filePath"];
BOOL worked = [[NSWorkspace sharedWorkspace] setIcon:[[NSImage alloc] initWithContentsOfFile:soundPath] forFile:filePath options:0];
NSLog(@"Worked: %i",worked);
[pool release];
return 0;
}