|
Paul's recent article on his favorite new Swift API from iOS 15 was about url.lines. In the first portion, where he lists quotes from a hard-coded URL (URL(string: "https://hws.dev/quotes.txt")!. If, instead of a hard-coded URL, the user had a choice, eg. from a local or iCloud file, what would be the best way to make such a choice. I've been trying with .fileImporter, but getting confused... |
|
My question was likely too vague to get a response. Here is the code I've been trying. if I uncomment the portion that Paul uses in his example, it works as expected. However, if I comment that out and use my line: let url = URL(string: String(describing: settings.fileURL))! then it does not list the contents of the file. Any suggestions? Here is the full code for ContentView:
|
|
Why are you doing this? Something like what Paul is doing is what you need to do. So force unwrap At any rate, you are running into problems because |
|
Thank you, roosterboy! I've used your suggestion to get this past the url hurdle. (I'm currently in an absurd situation where I click on the button to go to the file, choose the file, but then am presented with the button again, choose it, and then finally the List of contents shows up, but with the menu to choose a file still there. I've been staring at this to long...) Anyway, for those interested here's the code that sort of works, except for the absurdity...
|
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.