Why is the order of my array random when i use the @Model macro.
class TestModel {
var name: String?
var array: [TestModel2]
init(name: String = "") {
self.name = name
array = []
}
}
class TestModel2 {
var name: String?
init(name: String = "") {
self.name = name
}
}
This works fine, and all the items in array
are in the order I add them.
But if I declare both of them as @Model, like this:
@Model
class TestModel {
var name: String?
var array: [TestModel2]
init(name: String = "") {
self.name = name
array = []
}
}
@Model
class TestModel2 {
var name: String?
init(name: String = "") {
self.name = name
}
}
The array
items are always in a random order. When I reload the view where they are displayed or when I add items to the array
the order is randomised.
Is this a beta bug? Or is this intended?