runtime之forwardInvocation

methodSignatureForSelector:
原型:

– (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector 

這個函數和後面的forwardInvocation:是最後一個尋找IML的機會。這個函數讓重載方有機會拋出一個函數的簽名,再由後面的forwardInvocation:去執行。
forwardInvocation:
原型:

– (void)forwardInvocation:(NSInvocation *)anInvocation 

真正執行從methodSignatureForSelector:返回的NSMethodSignature。在這個函數裏可以將NSInvocation多次轉發到多個對象中,這也是這種方式靈活的地方。(forwardingTargetForSelector只能以Selector的形式轉向一個對象)

轉自:http://www.zhuayoukong.com/95301.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章