Is it right to say that paths are represented as URI while web-addresses are represented as URL?

北城余情 提交于 2019-12-10 12:17:58

问题


I am confused by Apple's documentation about the NSURL class.

In NSURL, they say the following:

  • NSURL understands URLs in style of RFC 1808, 1738 und 2732
  • NSURL understands URIs in style of RFC 2396

Also they say that the RFC 2396 URI are paths.

Now what's the difference here? Isn't a path also an URL? I mean, it's an location or not?


回答1:


Both URLs and URIs identify resources (which are anything). However, a URL is the term used for an identifier that specifies how to locate the resource.

Let's consider other kinds of identifiers to help make this clear. An ISBN code identifies a book but does not specify how to find it. A Dewey Decimal or Library of Congress number also identifies a book and is also used to organize books in a library -- given the number you can find the book on a shelf in the library.

Getting back to URIs and URLs, a URI that refers to the location or path of a file is by definition a URL.

NSURL can also be used to parse and manipulate URIs that do not locate resources but merely identify them.



来源:https://stackoverflow.com/questions/2109298/is-it-right-to-say-that-paths-are-represented-as-uri-while-web-addresses-are-rep

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!