ios - Swift: How to create instance of a class, if I have the name of the instance in a variable? -


i have team, teamscore, userscore information on parse. download , want store locally , update it. create team() class, have scores properties , creating instances of class team names downloaded parse. problem how create instance of class names parse downloaded team names?

or there simpler way solve problem without classes?

you can try that:

var classname = "teamclassname" var c = nsclassfromstring(classname) as? teamscoresuperclas.type if let cl = c {     println("ok") } else {     println("false") } 

you should have superclass team, score, etc classes. in example above pass team class name parameter if change score fine until superclass same.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -