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

How to store a complex structure data in Core Data?

Forums > SwiftUI

Hello, I want to storage a structure wtih more than 10 variable. The sturcture is like this:

var option_1: [String]
var option_2: [String]
// ...
var option_n: [String]

struct Item {
    var name: String

    // The following  variable attr_i can choose one option from option_i: [String]
    var attr_1: String
    var attr_2: String
    // ...
    var attr_n: String
}

And I want to show them in a List line by line. Howerver, List can get most 10 subview, so I can't list them like:

List {
  Text(item.name)

  // I alse want to make each attr_i could taggle from option_i: [String], 
  // for example by using Picker
  Text(item.attr_1)
  // ...
  Text(item.attr_n)
}

And create this many attribute in Core Data and use them one by one is imposible.I try to use ForEach to get the attribute of Item but I failed.

This problem makes me clueless and gets me nowhere

So I want to aks how could I get some structure that can storage in Core Data and CloudKit and alse I can show them in a easy way, and each attr_i could taggle from option_i: [String].

I would really appreciate it if you could help me or give me some hints.

2      

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.