[swift-evolution] Why does URL.checkResourceIsReachable() return a Bool?

Dave Abrahams dabrahams at apple.com
Mon Aug 8 19:54:29 CDT 2016


on Sun Aug 07 2016, Charles Srstka <swift-evolution at swift.org> wrote:

> -[NSURL checkResourceIsReachableAndReturnError:] has taken on several
> forms in Swift during its development, sometimes returning a Boolean
> and an error by reference, sometimes returning Void and using Swift’s
> do/try/catch system. In Swift 3, though, it appears to do both, which
> is weird:
>
> func checkResourceIsReachable() throws -> Bool
>
> All the documentation has to say about this is:
>
> "This method is currently applicable only to URLs for file system resources. For other URL types, false is returned.”
>
> It does not, however, say whether non-file URLs are the only thing
> that can cause a return of ‘false’, so I don’t know whether I should
> be checking the return value when checking a file URL or not. This
> results in having to check both the return value *and* the catch block
> each time, which is fairly awkward. I’m also not clear on why checking
> reachability on a non-file URL can’t just return an error like it did
> in the past.
>
> What’s the rationale behind this?

Hi Charles,

At least for now, discussion of the design of core libraries belongs on
swift-corelibs-dev, rather than swift-evolution.  That's where you'll
reach the people that can usefully respond.

HTH,

-- 
-Dave



More information about the swift-evolution mailing list