UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Reading a .txt file from an App

Forums > SwiftUI

So I am developing an app, for a classroom. Where you would be able to load a .txt file (of student names) into the app (so it wouldn't be in the Bundle). I've seen apps have that ability, where you create a .txt file, and then send it to your device (iPad/iPhone) clicking on the file to open it and then there is a export button, that allows you to select an app on your device.

Just working on the first step here so any help would be greatly appreciated!

Thank you.

Bob Lawson

3      

Break your big problem into smaller solvable problems. First where will you find your text file of student names? Probably it will be in your iPad's document directory. How do you find the user's private documents directory? HackingWithSwift has the answer!

Where are my documents?

Next, what's IN your documents directory.

@twostraws has a great tutorial on this as well.

What's in the document's directory

Wonder if HackingWithSwift has any tutorials on loading a file that you just found in your user's documents directory?

Reading and Writing Documents

Give these a try. Watch. Study. Experiment. Watch again! When you have questions on techniques or concepts, we're here to help.

4      

Well, aren't you in luck!

@twostraws has been updating his 100 Days of SwiftUI course. And today, 07 Dec 2021, he just updated the tutorial on reading and writing documents to the iOS documents folder. Timing!

Updated: Reading and Writing Documents

4      

Thank you! That's exactly what I'm doing, take it step by step!

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

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.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.