ios - How do I specify class name as variable in Swift? -
i want this: class dog: object { dynamic var name = "" dynamic var age = 0 } let results = realm.objects(dog) ...but specify object name variable. this doesn't work: let objectname = "dog" let results = realm.objects(objectname) neither this: let object = dog let results = realm.objects(object) ...or this: let object = dog() let results = realm.objects(object) ...or this: let object: dog let results = realm.objects(object) any ideas? you can reference type directly dog.self : let type = dog.self i don't have project realm, in theory should able like: let results = realm.objects(type)