Calling a function after using `createInstance()`
derLalla opened this issue · comments
Hey, is it possible to call a function (e.g. via String) of a class which is created by using createInstance()
?
I am creating test cases for Classes and check if a function was implemented correctly.
The idea is, that I provide an empty class, e.g. "Student" and a UML diagram which states that a Student has a function named "getStudentId()". A student now needs to implement the code.
Now I want to write a test case which tries to initialize the "Student" class and
1.) check if the function "getStudentId()" exists and
2.) check if it returns the correct value
I can check with
if let inferredClass = NSClassFromString("Student") {
...
} else {
print("no class found")
XCTFail("Student.swift is not implemented!")
}
that the class exists, but I cannot call the function.
Do you have an idea?