EvGeniy Ilyin
EvGeniy Ilyin

Reputation: 1929

class_copyMethodList is not working on a Swift class

How I can get all methods names from swift class? I try used class_copyMethodList, but it is not working for swift... I need get all methods names including all extension of my class.

  1. How I can do it for clear Swift class?

Global task: I need get all methods names from my class, filtered it by prefix, and call it one by one.

Upvotes: 1

Views: 484

Answers (1)

Code Different
Code Different

Reputation: 93191

class_copyMethodList is a function from the ObjectiveC runtime. As expected, it only works on Objective C classes. Make your class inherit from NSObject:

class MyClass: NSObject {
    // ....
}

Upvotes: 3

Related Questions