Swift - can not write Array into Realm
I'm trying to write Array (with GPS coordinates), but now i even can not write Array with String.
My code:
import RealmSwift
import UIKit
class ViewController: UIViewController {
let realm = try! Realm()
override func viewDidLoad() {
super.viewDidLoad()
save()
render()
}
func save(){
let joe = Person()
joe.trackPoint = ["aaa", "bbb", "ccc"]
print("Array write")
realm.beginWrite()
realm.add(joe)
try! realm.commitWrite()
}
func render(){
let people = realm.objects(Person.self)
for person in people{
print(person.trackPoint)
print("Read ok")
}
}
}
class Person: Object{
@objc dynamic var firstName: String = ""
@objc dynamic var lastName: String = ""
var trackPoint: [String] = []
}
And my console:
Array write
[]
Read ok
[]
Read ok
Array trackPoint don't write into Realm...
Please, help