---
title: "@selector creation with method name and parameter"  
description: "@selector creation with method name and parameter"  
author: "Anonymous User"  
published: 2015-11-09  
updated: 2015-11-15  
canonical: https://www.mindstick.com/forum/33583/selector-creation-with-method-name-and-parameter  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# @selector creation with method name and parameter

I created a [sample](https://www.mindstick.com/news/2174/mars-mission-by-nasa-prepares-for-tests) that gets a SEL from currentObject,\
SEL [callback](https://www.mindstick.com/articles/152/using-the-callback) = @[selector](https://www.mindstick.com/interview/23419/action-selector-in-mvc)(methodName: parameterTwo);\
Andalso I have a [method](https://www.mindstick.com/forum/166/webservice-method) like this:

```
- (void) methodName: (id) var1 parameter2;(NSString*) var2 {}
```

[Now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now) I want to move methodName to another object, with passing delegateObj.\
This is the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) that I have tried:

```
SEL callback = @selector(myDelegate, mymethod:parameter2);
```

but it’s not working, please [anyone tell me](https://www.mindstick.com/interview/23033/can-anyone-tell-me-about-hadoop-toolbox) the reason.\

## Replies

### Reply by Tarun Kumar

It looks like you are trying to implement a callback. The best way to do is something like this:

```
[object setCallbackObject:self withSelector:@selector(myMethod:)];
```

We can not pass parameter's in a @ selector().\
Then in our object's setCallbackObject:withSelector: method: we can call your callback method.

```
-(void)setCallbackObject:(id)anObject withSelector:(SEL)selector {    [anObject performSelector:selector];}
```


---

Original Source: https://www.mindstick.com/forum/33583/selector-creation-with-method-name-and-parameter

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
