Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
To instantiate a Swift class dynamically using NSClassFromSwift. This works for ObjC as well as pure Swift classes.
class YourClass {
required init() {
func saySomething() {
if let classType = NSClassFromString("APPNAMEORMODULE.YourClass") as? YourClass.Type {
let object = classType.init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment