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 –
非常感謝你 –