我想做这样的事情:
class Dog: Object {
dynamic var name = ""
dynamic var age = 0
}
let results = realm.objects(Dog)
...但是将对象名称指定为变量。
这不起作用:
let objectName = "Dog"
let results = realm.objects(objectName)
这两个都没有:
let object = Dog
let results = realm.objects(object)
......或者这个:
let object = Dog()
let results = realm.objects(object)
......或者这个:
let object: Dog
let results = realm.objects(object)
有什么想法吗?
答案 0 :(得分:1)
您可以使用let type = Dog.self
直接引用该类型:
let results = realm.objects(type)
我没有带有领域的项目,但从理论上讲,你应该可以做类似的事情:
city1$NY <-as.numeric(levels(city1$NY))[city1$NY]
city1$CHI<-as.numeric(levels(city1$CHI))[city1$CHI]
city1$LA <-as.numeric(levels(city1$LA))[city1$LA]
city1$ATL<-as.numeric(levels(city1$ATL))[city1$ATL]
city1$MIA<-as.numeric(levels(city1$MIA))[city1$MIA]