After a lot of trouble, I finally got my code converted to Swift 3.0.
But it looks like my incrementID function no longer works?
Any suggestions how can I fix this?
My incrementID and primaryKey functions look right now.
override static func primaryKey() -> String? { return "id" } func incrementID() -> Int{ let realm = try! Realm() let RetNext: NSArray = Array(realm.objects(Exercise.self).sorted(byProperty: "id")) as NSArray let last = RetNext.lastObject if RetNext.count > 0 { let valor = (last as AnyObject).value(forKey: "id") as? Int return valor! + 1 } else { return 1 } }
source share