Skip to content

Instantly share code, notes, and snippets.

Created October 25, 2017 20:58
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