How to find out whether a given class serves as a delegate for an object?
In Objective-C, how can one find out whether a given class serves as 开发者_JS百科a delegate for a given type of an object?
A book i am reading suggest examining the .h file, however i am not sure exactly what to look for. How would .h file declare that it's .m is a delegate for some object?
Please clarify.
If the delegating class has a protocol for its delegate, you could check whether the class conforms to that protocol. Otherwise, look for the methods that the delegate is supposed to implement (e.g. the tableView:…:
family of methods for an NSTableView delegate).
精彩评论