Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating alias to app for PDFService



Hi,

I'm trying to get my app to install itself as a PDF Service. Although I manage to create the PDFService directory if it doesn't yet exist, I can't get the alias to be created. The code I've written for it looks like this:

- (IBAction)installAsPDFService:(id)sender
{
NSArray *paths;
BOOL isDir = NO, exists = NO, success = NO;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *pdfServiceDirectoryPath, *myAppAliasPath, *myAppPath;

paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
if ([paths count] > 0) { // only copying one file
pdfServiceDirectoryPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"PDF Services"];
exists = [fileManager fileExistsAtPath:pdfServiceDirectoryPath isDirectory:&isDir];
if (!isDir) {
// There is no PDF Services directory so create it
[fileManager createDirectoryAtPath:pdfServiceDirectoryPath attributes:nil];
}


myAppAliasPath = [pdfServiceDirectoryPath stringByAppendingPathComponent:@"myApp"];
exists = [fileManager fileExistsAtPath:myAppAliasPath];
if (!exists) {
// There is no alias to myApp so create it
myAppPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingPathExtension];
success = [fileManager linkPath:myAppPath toPath:pdfServiceDirectoryPath handler:nil];
}
}
}


But the last call to the linkPath method always returns NO and no alias is created. I've tried the myAppPath with and without the path extension. No joy either way. Can anybody tell me where I'm going wrong?

Thanks,
António _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.