swift - Accessing primitive types in RealmSwift -


i using objectmapper along realmswift , class looks like:

class location: object, mappable {     var lat : float = 0     var lng : float = 0      required convenience init?(_ map: map) {         self.init()     }      func mapping(map: map) {         lat <- map["lat"];         lng <- map["lng"];     } } 

this location class referenced in class vehicle.swift subclass of realm object

i able access location of vehicle using line:

let location : location = vehicle.vehiclelocation! 

printing value of location gives me output:

location  location {     lat = 49.24122;     lng = -123.1153; } 

i opened realm database using realm browser , values correspond in database.

however when try to access lat , lng values, getting 0.0. trying access these using :

let lat : float = vehicle.vehiclelocation!.lat let lng : float = vehicle.vehiclelocation!.lng  

any idea might happening ?

all stored realm properties must defined dynamic.

change:

var lat : float = 0 var lng : float = 0 

to:

dynamic var lat : float = 0 dynamic var lng : float = 0 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -