KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Snow Leopard introduced many new methods to use NSURL objects to refer to files, not pathnames or Core Services' FSRefs. 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 -[NSFileManager fileExistsAtPath: ] . Like that method, it should return YES if the URL describes anything, whether it's a regular file, a directory, or anything else. I could attempt to look up various resource values , but none of them are explicitly guaranteed to not exist if the file doesn't, and some of them (e.g., NSURLEffectiveIconKey ) could be costly if it does. I could just use NSFileManager's fileExistsAtPath: , but if there's a more modern method, I'd prefer to use that. 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?
Tags (comma-separated)
Save Edits
Cancel