JohnSundell / JohnSundell/Files

URL vs String

Open
#59 17 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
2.6k
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Discussion

Would it be better to return instances of [URL](https://developer.apple.com/documentation/foundation/nsurl) wherever possible, instead of stringPath ?

> URL objects are the preferred way to refer to local files. Most objects that read data from or write data to a file have methods that accept an NSURL object instead of a pathname as the file reference. For example, you can get the contents of a local file URL as an NSString object using the init(contentsOf:encoding:) initializer, or as an NSData object using the init(contentsOf:options:) initializer.

> You can also use URLs for interapplication communication. In macOS, the NSWorkspace class provides the open(_:) method to open a location specified by a URL. Similarly, in iOS, the UIApplication class provides the openURL(_:) method.

> Additionally, you can use URLs when working with pasteboards, as described in NSURL Additions Reference (part of the AppKit framework).

> The NSURL class is “toll-free bridged” with its Core Foundation counterpart, CFURL. See Toll-Free Bridging for more information on toll-free bridging.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.