-1

If I have app A with class called Hello and in it function called

helloworld which print "hello world" statement and I want to use this class

in another app B and dynamically load hello class in runtime and use

helloworld method can any one help me pleaseee??!

1 Answers1

4

If I'm understanding you correctly, you can use NSClassFromString. Do keep in mind that iOS doesn't use any real namespacing so your class string will have to be "SourceAppName.ClassName" like so:

let className = "SourceAppName.SomeViewControllerOrClass"
let grabbedClass = NSClassFromString(className!) as! UIViewController.Type
let helloWorldClass = grabbedClass.init()
Cole
  • 2,641
  • 1
  • 16
  • 34