ios - Map core data row from one table (entity) to an array of [CLLocation]? -
in ios app using core data , need save in table array of "regions" json.
the model "region" object quite simple:
class region : nsobject, nscoding { ... //mark: - //mark: - properties fileprivate var id: string fileprivate var name: string fileprivate var boundarypoints: [cllocation] fileprivate var midcoordinate: cllocationcoordinate2d { return getpolygonfromboundarypoints().coordinate } init(id: string, name: string, boundarypoints: [cllocation]) { self.id = id self.name = name self.boundarypoints = boundarypoints super.init() } //mark: - //mark: - nscoding ... //mark: - //mark: - getters , setters ... }
the problem need persist in table record this:
regions table:
id | title | [cllocation]
what best solution mapping row array of (lat,lng) points ( in case [cllocation]) when storing information "region" object ? "region" object model contains array of boundary points.
in words how should go saving object model has array property sql using core data ? (interested in tables' structure , relationships)
you need store value in core data transformable
, use value transformer. can find tutorial more details here: http://lextech.com/2013/01/core-data-transformable-attributes/
Comments
Post a Comment