TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Coredata svind in sequence

Forums > SwiftUI

Hello,

I would like to save a text in coredata but in a sequence of questione.

Question 1 Input Text Button Save -->

Question 2 Input Text Button Save -->

.... 3..4...5

witch strategy you suggest to manage the sequence and to save the text in the same records?

Thanks

2      

@Bnerd  

I guess you should have an Entity i.e. Question, that has two attributes questionNumber: Int questionText: String

If you are not planning on deleting questions in the future, you could just create each new question by providing a questionNumber as per the Question.count i.e. questionNumber = Question.count + 1

if you plan to be able to delete questions the above will not work, but you could add a questionDateCreated: Date attribute in your Question and sort your questions. This way you could re-assign the questionNumber depending on the sorting.

Just ideas :) I hope they will help you.

2      

Hacking with Swift is sponsored by RevenueCat.

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.

Learn more here

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.