• 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
Re: path name from Apple Event
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: path name from Apple Event


  • Subject: Re: path name from Apple Event
  • From: Bill Monk <email@hidden>
  • Date: Mon, 15 Aug 2005 09:21:14 -0500


Gerriet M. Denkmann wrote:

Given an NSAppleEventDescriptor of typeAlias = 'alis' - how do I get
the path as an NSString?

Coerce typeAlias to typeFileURL, which is an HFS-style colon- delimited pathname.
The use CFURLto get a slash-delimited pathname as an NSString.


Below is a method to do the job.

Regards,
Bill Monk

-(NSString *)posixPathFromAliasDesc:(NSAppleEventDescriptor *)aliasDesc
{
    CFStringRef posixPath = NULL;

// coerce typeAlias to typeFileURL, a colon-delimited HFS-style pathname
NSAppleEventDescriptor *urlDesc = [aliasDesc coerceToDescriptorType:typeFileURL];
NSString *hfsPath = [urlDesc stringValue];


// make CFURL from HFS path
BOOL isHFSDirectoryPath = [hfsPath hasSuffix:@":"];
CFURLRef myURLRef = CFURLCreateWithFileSystemPath ( kCFAllocatorDefault,
(CFStringRef) hfsPath ,
kCFURLHFSPathStyle,
isHFSDirectoryPath );
if (NULL != myURLRef) {


// make POSIX path from CFURL
posixPath = CFURLCopyFileSystemPath( myURLRef, kCFURLPOSIXPathStyle );
CFRelease( myURLRef );


        if (NULL != posixPath) {
            [(NSString *)posixPath autorelease];
        }
    }

    return (NSString *)posixPath;
}


_______________________________________________ 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
  • Follow-Ups:
    • Re: path name from Apple Event
      • From: glenn andreas <email@hidden>
  • Prev by Date: Re: CoreData "Could Not Merge Changes"
  • Next by Date: Custom PopUpButton: IB Connection not holding at runtime
  • Previous by thread: Re: path name from Apple Event
  • Next by thread: Re: path name from Apple Event
  • Index(es):
    • Date
    • Thread