Find out what the difference is between a URL and a path, and learn how to create your own useful URLs.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4307-saving-data-in-ios/lessons/3
Find out what the difference is between a URL and a path, and learn how to create your own useful URLs.
Really great tutorials, just have one question regarding:
let stringURL = FileManager.documentDirectoryURL.appendingPathComponent(âstringâ).appendingPathExtension(âtxtâ)
I know that property stringUrl is a string url path. But is this creating an empty text document called âstring.txtâ in the userâs document directory, or is it a url path to a text document that does not exist called âstring.txtâ? Thanks.
The document will not exist until we write data to stringURL
. So itâs the second situation youâve asked about, that the URL represents. You can create URL instances without any fear of cluttering up the document directory, for example.
Side note: An important distinction is that stringURL
is not a path itself, but an instance of Foundationsâs URL
struct. The URL has a path, which is just a string that holds what might elsewhere be called a URL. This terminology might be different in other environments, but itâll be helpful to keep in mind for Cocoa Touch development.
running into a few issuesâŠwhat is shown in the video doesnât line up with what I get. The issue is with what is shown when I hit the eye or check the box. is will give me a empty file rather then the text.
I tested the fact of me getting that empty file with that let statement belowâŠit shows that fine but not the other.
Hey!
What youâre seeing is exactly what you should be seeing (even though itâs not very helpful! ) Youâre missing the
.path
property usage, which is the last thing we did in this video, on lines 6 and 9.
What is the difference between URL and Filemanager.default
Sorry, but this episode stopped me
Do you mean that I can get the URL either by FileManager class or URL ⊠could you explain this point ⊠It missed in the video??
What is the URL for ??
Which URL in particular are you asking about?
thx jessy for your help
I wil read the links above
seems clear now
I have this error
Playground execution failed:
error: MyPlayground.playground:5:1: error: instance member âdocumentDirectoryURLâ cannot be used on type âFileManagerâ
FileManager.documentDirectoryURL
^~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Although i did everything like video and save
@jessycatterwaul Can you please help with this when you get a chance? Thank you - much appreciated! :]
Also this error
error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0).
The process has been left at the point where it was interrupted, use âthread return -xâ to return to the state before expression evaluation.
I just checked out the â3 - Endâ version of the playground, and didnât have this problem. My best guess is that you missed the static
keyword, but itâs possible that you just didnât wait long enough for the playground to compile. If youâre still having trouble, please upload your version and Iâll have a look at it!
This topic was automatically closed after 166 days. New replies are no longer allowed.