• 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: NSRecentDocumentRecords - dynamically updating
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSRecentDocumentRecords - dynamically updating


  • Subject: Re: NSRecentDocumentRecords - dynamically updating
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 13 Mar 2007 21:36:28 -0700
  • Thread-topic: NSRecentDocumentRecords - dynamically updating

James,

>From reading your post, I'm not sure what you want to do.  Most of what you
said will work.  For example, if you want to get a path from that
"_NSAlias", you just get that -objectForKey, cast it as an NSData and
resolve the alias.  I've pasted in a function I use to do that; I don't know
maybe this is the same as what you've already found...

Jerry Krinock

NSString* SSPathResolveFromAliasData(NSData* data) {
    NSString* path = nil ;
    if (data) {
        if (CFDataGetTypeID() == CFGetTypeID((CFDataRef)data)) {
            // now convert the CF data back into an alias
            CFIndex dataSize = CFDataGetLength((CFDataRef)data) ;
            AliasHandle tAliasHdl = (AliasHandle)NewHandle(dataSize) ;
            if (tAliasHdl) {
                CFDataGetBytes(
                   (CFDataRef)data,
                   CFRangeMake(0,dataSize),
                   (UInt8*)*tAliasHdl) ;
                FSRef fsRef;
                Boolean wasChanged;
                // Try to resolve the alias ...
                // The following can delay for several minutes before timing
out
                // if the alias is on a volume which is not now mounted.
                // There is a related function which aborts if user
                // interaction is needed; I haven't tried that
                OSErr err = FSResolveAlias(
                           NULL, tAliasHdl, &fsRef, &wasChanged) ;
                char pathC[2048] ;
                if (err == noErr) {
                    err = FSRefMakePath(&fsRef, (UInt8*)pathC,
sizeof(pathC)) ;
                }
                if (err == noErr) {
                    path = [NSString stringWithCString:pathC] ;
                }
            }
        }
    }

    return path ;
}



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSRecentDocumentRecords - dynamically updating
      • From: "James Wettenhall" <email@hidden>
References: 
 >NSRecentDocumentRecords - dynamically updating (From: "James Wettenhall" <email@hidden>)

  • Prev by Date: Re: NSURLConnection leaking on multi-threaded apps?
  • Next by Date: Re: NSRecentDocumentRecords - dynamically updating
  • Previous by thread: NSRecentDocumentRecords - dynamically updating
  • Next by thread: Re: NSRecentDocumentRecords - dynamically updating
  • Index(es):
    • Date
    • Thread