---
title: "What is the Use of Selectors in Objective C"  
description: "What is the Use of Selectors in Objective C"  
author: "Tarun Kumar"  
published: 2015-09-18  
updated: 2020-09-21  
canonical: https://www.mindstick.com/interview/22831/what-is-the-use-of-selectors-in-objective-c  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# 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];

## Answers

### Answer by Tarun Kumar

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];


---

Original Source: https://www.mindstick.com/interview/22831/what-is-the-use-of-selectors-in-objective-c

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
