1
我想获得一个类的方法列表。这里是我的代码“class_copyMethodList”只返回init方法
class MyClass: NSObject {
func method1(){
print("Method1")
}
func method2(){
print("Method2")
}
}
var methodCount: UInt32 = 0
let methodList = class_copyMethodList(MyClass.self, &methodCount)
for i in 0..<Int(methodCount){
let unwrapped = methodList?[i]
print(NSStringFromSelector(method_getName(unwrapped!)))
}
输出是:
init
method1
和method2
则无法在输出显示。
请纠正我,如果我做错了什么。帮助将被appriciated。
谢谢
您在使用雨燕4?看看https://stackoverflow.com/questions/44390378/how-can-i-deal-with-objc-inference-deprecation-with-selector-in-swift-4 –
非常感谢你 –