If you want to do something like this I believe you should have one ModelContainer but with multiple ModelConfiguration objects.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
You have a complex and dynamic design which will make the whole solution more complex. When you write "...sort the inspections based on the values only in fields with specific labels" it not only is an example of the complexity but it is quite frankly hard to understand how/if it should work. An inspection can have many groups and a group can have many rows so even if you are only sorting on one label with a specific field it will be a complex task to sort the rows and groups for a single inspection not to mention comparing inspections.
Since I have no idea what an inspection is in this context and neither what your fields will be filled with it's hard to give any kind of advice but for starters, do you really, really need to sort the inspectors in this manner?
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
Did you try without a custom migration, since the property has a default value it should work automatically?
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
It doesn't work well when all objects you want to add are new and haven't been inserted before. Try to first insert the Item object before adding the SubItem objects.
For example
let item = Item(name: "Item1", subitems: [])
container.mainContext.insert(item)
item.subitems.append(SubItem(name: "subItemA"))
item.subitems.append(SubItem(name: "subItemB"))
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
Not cities.country.name but if you have a single city obj selected then city.country.name will work
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
You have a unique requirement on the attribute pair so there is only one Account object that has a given combination of the two attribute.
Doesn’t that mean that you can skip the tuple and instead use the id property in your code? That is still use map and the same predicate but with id (or persistentModelId) instead of the tuple?
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
You have a single Category object that you update inside the loop instead of creating a new category for each iteration.
Remove the category property and change your loop to something like this
for index in 0..<model.dataTable!.rows.count {
let row = model.dataTable!.rows[index]
let name = row["Catagory"] as! String
let category = Category(id: UUID(), name: name, instrumen: [[)
context.insert(catagory)
print(catagory.name)
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
You are calling the wrong method, instead do
modelContext.delete(model: MyModel.self)
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
You could create a constant variable and pass that
let container = self.modelContext.container
someFunc(container: container)
Topic:
Programming Languages
SubTopic:
Swift
Tags:
If you want to do something like this I believe you should have one ModelContainer but with multiple ModelConfiguration objects.
- Replies
- Boosts
- Views
- Activity
You have a complex and dynamic design which will make the whole solution more complex. When you write "...sort the inspections based on the values only in fields with specific labels" it not only is an example of the complexity but it is quite frankly hard to understand how/if it should work. An inspection can have many groups and a group can have many rows so even if you are only sorting on one label with a specific field it will be a complex task to sort the rows and groups for a single inspection not to mention comparing inspections.
Since I have no idea what an inspection is in this context and neither what your fields will be filled with it's hard to give any kind of advice but for starters, do you really, really need to sort the inspectors in this manner?
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
- Replies
- Boosts
- Views
- Activity
Did you try without a custom migration, since the property has a default value it should work automatically?
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
- Replies
- Boosts
- Views
- Activity
It doesn't work well when all objects you want to add are new and haven't been inserted before. Try to first insert the Item object before adding the SubItem objects.
For example
let item = Item(name: "Item1", subitems: [])
container.mainContext.insert(item)
item.subitems.append(SubItem(name: "subItemA"))
item.subitems.append(SubItem(name: "subItemB"))
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
- Replies
- Boosts
- Views
- Activity
Not cities.country.name but if you have a single city obj selected then city.country.name will work
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
- Replies
- Boosts
- Views
- Activity
You have a unique requirement on the attribute pair so there is only one Account object that has a given combination of the two attribute.
Doesn’t that mean that you can skip the tuple and instead use the id property in your code? That is still use map and the same predicate but with id (or persistentModelId) instead of the tuple?
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
- Replies
- Boosts
- Views
- Activity
You have a single Category object that you update inside the loop instead of creating a new category for each iteration.
Remove the category property and change your loop to something like this
for index in 0..<model.dataTable!.rows.count {
let row = model.dataTable!.rows[index]
let name = row["Catagory"] as! String
let category = Category(id: UUID(), name: name, instrumen: [[)
context.insert(catagory)
print(catagory.name)
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
You are calling the wrong method, instead do
modelContext.delete(model: MyModel.self)
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
You could create a constant variable and pass that
let container = self.modelContext.container
someFunc(container: container)
Topic:
Programming Languages
SubTopic:
Swift
Tags:
- Replies
- Boosts
- Views
- Activity