WHAT IS THE USE OF SELECTORS IN OBJECTIVE C

Tarun Kumar

Total Post:107

Points:535
Posted by  Tarun Kumar
 562  View(s)
Ratings:
Rate this:
  1. Tarun Kumar

    Post:107

    Points:535
    What is the Use of Selectors in Objective C

    In Objective-C, selector has two meanings. It can be used to refer simply to the name of a method when it’s used in a source-code message to an object. It also, though, refers to the unique identifier that replaces the name when the source code is compiled. Compiled selectors are of type SEL. All methods with the same name have the same selector. You can use a selector to invoke a method on an object—this provides the basis for the implementation of the target-action design pattern in Cocoa.

    [myColor performSelector:@selector(setColor:) withObject:green];

    is equivalent to:

    [myColor setColor:green];

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!