'swiftUI list realm... Table is rendered twice
I have simple View with Realm and swftUI List... When the table is rendered, i see, that after few seconds table rendered again. Because of this i can not use swipe options on table: delete, edit... I can not understand it. Please help...
import Foundation
import SwiftUI
import RealmSwift
import MapKit
struct TracksController: View {
let realm: Realm
var body: some View{
NavigationView{
VStack {
listView(realm: realm)
Button(action: {
print("refresh")
}) {
Text("Обновить")
}
}
}
}
struct listView: View {
let realm: Realm
var body: some View {
List{
ForEach(realm.objects(trackList.self) , id: \.self) { elem in
Text(String(elem.coordinates.count))
}.onDelete(perform: deleteRow)
}
}
func deleteRow(at offsets: IndexSet) {
print(IndexSet.self)
}
}
}
class locationList: Object {
@objc dynamic var latitude = 0.0
@objc dynamic var longitude = 0.0
/// Computed properties are ignored in Realm
var coordinate: CLLocationCoordinate2D {
return CLLocationCoordinate2D(
latitude: latitude,
longitude: longitude)
}
}
class trackList: Object {
let coordinates = RealmSwift.List<locationList>()
@objc dynamic var nameTrack: String = ""
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
