• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
LSGetApplicationForItem -or- my crazy adventure with launch services
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LSGetApplicationForItem -or- my crazy adventure with launch services


  • Subject: LSGetApplicationForItem -or- my crazy adventure with launch services
  • From: email@hidden
  • Date: Wed, 5 Sep 2001 23:11:04 -0700

I am using launch services quit a but in my app, but I am having some troubles. I don't really get a lot of it, so this is me walking blindly through header files.

I am trying to get the application that a file will open in, but I crash because of SIGSEGV (segmentation i think)

here's the relevant code:

- (void)getFileInfo:(NSString *)fullPath
{
FSRef ref;
FSPathMakeRef([fullPath cString], &ref, NULL);
if (![manager fileExistsAtPath:fullPath isDirectory:&isDir] || !isDir)
{
[opensWithField setStringValue:(NSString *)LSGetApplicationForItem(&ref, kLSRolesAll, NULL, NULL)];
}
}

there is other stuff in there. The full function is:

- (void)getFileInfo:(NSString *)fullPath
{
NSFileManager *manager = [NSFileManager defaultManager];
NSDictionary *fattrs = [manager fileAttributesAtPath:fullPath traverseLink:YES];
FSRef ref;
BOOL isDir;
FSPathMakeRef([fullPath cString], &ref, NULL);
[dirField setStringValue:fullPath];
if (![manager fileExistsAtPath:fullPath isDirectory:&isDir] || !isDir)
{
[typeField setStringValue:RemoveQuotesFromString(NSHFSTypeOfFile(fullPath))];
[creatorField setStringValue:RemoveQuotesFromString(HFSCreatorOfFile(fullPath))];
[sizeField setStringValue:[[fattrs objectForKey:NSFileSize] stringValue]];
[ownerField setStringValue:[fattrs objectForKey:NSFileOwnerAccountName]];
[groupField setStringValue:[fattrs objectForKey:NSFileGroupOwnerAccountName]];
[opensWithField setStringValue:(NSString *)LSGetApplicationForItem(&ref, kLSRolesAll, NULL, NULL)];
}
else
{
[typeField setStringValue:@""];
[creatorField setStringValue:@""];
[sizeField setStringValue:@""];
[ownerField setStringValue:@""];
[groupField setStringValue:@""];
[opensWithField setStringValue:@""];
}
}

thanks,
sam


  • Follow-Ups:
    • Re: LSGetApplicationForItem -or- my crazy adventure with launch services
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: -runModalForWindow and drawers
  • Next by Date: rotating windows 90 degreesin interface builder
  • Previous by thread: Re: mail server in mac
  • Next by thread: Re: LSGetApplicationForItem -or- my crazy adventure with launch services
  • Index(es):
    • Date
    • Thread