문제

Objc runtime provides a function, class_addMethod(), to try adding an instance method at runtime.

Is there any function which could try adding an class method to a class at runtime? Or, how can I achieve this purpose?

도움이 되었습니까?

해결책

Just add the method to the metaclass of the class. Every non-meta class is an instance of its metaclass, so a class method is really just an instance method of a metaclass.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top