Skip to content

Calling a function after using createInstance() #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
derLalla opened this issue Feb 1, 2021 · 0 comments
Open

Calling a function after using createInstance() #82

derLalla opened this issue Feb 1, 2021 · 0 comments

Comments

@derLalla
Copy link

derLalla commented Feb 1, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant