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

Best practice to to 'separate' app data and the data from the user

Forums > SwiftUI

Need advice: best way to 'separate' app data and the user data in Swift(UI). F.i. in the app is a book database, and a user can add his/her notes. When I update the app with new functions and new books, the notes from the user should not get lost.

Maybe use JSON for the books and Core Data for the notes? What is the best practice? Any publication or course?

3      

We will assume that your book data is hard-coded into the app? This is not really the best way to maintain an app like this if you need to redistribute the app whenever a new book is added.

In your shoes I would keep the book data, which is to be available to all users, on a central server (e.g. a web server) and load the data from there when you start the app. JSON is probably as good a format as any for holding that data and I seem to remember that Paul has a nice and simple set of videos on how to read and parse JSON data into your app.

We further assume that you keep the user's comments private on the local device. I have not looked at other alternatives, but using Core Data for this seems to make perfect sense to me.

So it sounds like you have the right solutions in mind and just need to be clear about what goes where.

Best of luck!

3      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.