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

SOLVED: Read and Write JSON to documents directory

Forums > iOS

Hi All,

I am very new to SwiftUI and have been working through Apple's Tutorial (https://developer.apple.com/tutorials/swiftui).

I have finished the tutorial and wanted to go one step further and allow the app user to add to and edit the landmarks currently stored in the JSON in the main bundle.

I understand that this is not possible and that I would need to copy the JSON to the Documents Directory and then read/write from there.

I cannot work out how to do this.

Is it possible? If so how would i go about it?

Thanks in advance!



You only reference Apple's tutorial. Yet, you are on one of the BEST SwiftUI sites in the world.

Which of the HackingWithSwift tutorials have you watched regarding JSON and JSON decoders?

You have a very generic question. Start with @twostraws' tutorials. Work your way through his 100 Days of SwiftUI videos and assignments. When you have specific questions about JSON, SwiftUI code, or concepts, we'll be here ready to help.


In this video by Stewart Lynch shows how to do save JSON to FileDirectory

JSON Decoding Playground for Swift

I think also that 100 Days of SwiftUI is about to do it starting at Day 68 – Project 14, part one


Hacking with Swift is sponsored by Superwall

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

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.