Re: How to check if file exists?
Re: How to check if file exists?
- Subject: Re: How to check if file exists?
- From: Charles Srstka <email@hidden>
- Date: Sat, 10 May 2014 17:17:13 -0500
On May 10, 2014, at 4:32 PM, Kyle Sluder <email@hidden> wrote:
> On May 10, 2014, at 1:27 PM, Charles Srstka <email@hidden> wrote:
>
>> On May 10, 2014, at 2:25 PM, Quincey Morris <email@hidden> wrote:
>>
>>> -[NSFileManager fileExistsAtPath:] is pretty much legacy API nowadays (and it’s significant that there’s no URL-based version of it).
>>
>> Sure there is; -[NSURL checkResourceIsReachableAndReturnError:].
>
>
> True enough. However, from the documentation for that method:
>
>> If your app must perform operations on the file, such as opening it or copying resource properties, it is more efficient to attempt the operation and handle any failure that may occur.
That's true. However, it also says:
> Checking reachability is appropriate when making decisions that do not require other immediate operations on the resource, such as periodic maintenance of user interface state that depends on the existence of a specific document. For example, you might remove an item from a download list if the user deletes the file.
Since that's the case Quincey was talking about (greying out files that don't exist in the UI), I'd say checkResourceIsReachableAndReturnError: is the appropriate API to use. It's certainly more efficient than reading the file just to see if it exists.
Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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