Home > DeveloperSection > Interviews > What is the Use of Selectors in Objective C

Posted on    September-18-2015 12:06 AM

 iPhone iPhone  Ios  Objective C 
Ratings:
 1 Answer(s)
  381  View(s)
Rate this:

Tarun Kumar

Total Post:107

Points:535
Posted on    September-18-2015 12:06 AM

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];


Don't want to miss updates? Please click the below button!

Follow MindStick