Ray's playground

 

Polymorphism, Dynamic Typing, and Dynamic Binding(Chapter 9 of Programming in Objective-C 2.0)

  To generate one of the so-called selectors listed in Table 9.1, you apply the @selector directive to a method name. For example, the following produces a value of type SEL for the method named alloc, which you know is a method inherited from the NSObject class:
  @selector (alloc)
  The following expression produces a selector for the setTo:over: method that you implemented in your Fraction class (remember those colon characters in the method names):
  @selector (setTo:over:)
  To see whether an instance of the Fraction class responds to the setTo:over: method, you can test the return value from the expression, like this:
  [Fraction instancesRespondToSelector: @selector (setTo:over:)]

 

posted on 2010-10-17 13:50  Ray Z  阅读(349)  评论(0编辑  收藏  举报

导航