Note that there are some explanatory texts on larger screens.

plurals
  1. POTesting file existence using NSURL
    primarykey
    data
    text
    <p>Snow Leopard introduced many new methods to use NSURL objects to refer to files, not pathnames or Core Services' FSRefs.</p> <p>However, there's one task I can't find a URL-based method for: Testing whether a file exists. I'm looking for a URL-based version of <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/fileExistsAtPath:" rel="noreferrer">-[NSFileManager <code>fileExistsAtPath:</code>]</a>. Like that method, it should return <code>YES</code> if the URL describes anything, whether it's a regular file, a directory, or anything else.</p> <p>I could attempt to look up various <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURL/resourceValuesForKeys:error:" rel="noreferrer">resource values</a>, but none of them are explicitly guaranteed to not exist if the file doesn't, and some of them (e.g., <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSURLEffectiveIconKey" rel="noreferrer">NSURLEffectiveIconKey</a>) could be costly if it does.</p> <p>I could just use NSFileManager's <code>fileExistsAtPath:</code>, but if there's a more modern method, I'd prefer to use that.</p> <p>Is there a simple method or function in Cocoa, CF, or Core Services that's guaranteed/documented to tell me whether a given file (or file-reference) URL refers to a file-system object that exists?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload