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) 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -