Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
let pred = NSPredicate(format: "slug = 'default'")
if let item: FolderData = databaseProvider.firstObject(type: DataModelType.folderData, predicate: pred) {
let realm = RealmConfigurator.shared.reamInstance()
try! realm.write {
item.mapping(map: Map(mappingType: .fromJSON, JSON: ["test": "Whaaaat?"]))
}
}
class FolderData: ObjectMappable, PonsoConvertibleProtocol {
dynamic var slug: String?
dynamic var title = ""
dynamic var test = ""
var statuses = List<StatusData>()
required convenience init?(map: Map) {
self.init()
}
// Mappable
override func mapping(map: Map) {
super.mapping(map: map)
if map.mappingType == .fromJSON {
if slug == nil {
slug <- map["slug"]
}
} else {
slug >>> map["slug"]
}
title <- map["title"]
statuses <- (map["statuses"], ListTransform<StatusData>())
test <- map["test"]
}
override class func primaryKey() -> String {
return "slug"
}
}
@alobanov

This comment has been minimized.

Copy link
Owner Author

alobanov commented Aug 16, 2017

Обновится только значение Test. Значение Title останется прежним

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.