• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1008
  • Last Modified:

Selector with arguments

Hi experts,

I'm really new to iOS programming (a week in fact) and I was wondering if anyone could tell me how to pass a selector with arguments in a method.

I get the "Expected ')'  before '(' token error.

How do I do this correctly?
Thanks in advance.
// This is the method

// This is what I'm trying to do and should be doing according to the documentation, but it gives an error
      UIBarButtonItem* rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(setIsEditing:YES)];

Open in new window

1 Solution
You can send information with the selector using UserInfo.  For example, create an NSDictionary and add some objects and keys to it.  When the method is called, you are able to receive that userinfo.

For example, set up your selector method like so:

-(void)myMethod:(NSTimer *)theTimer {


Open in new window

Then retrieve the information in your userInfo by doing something along the lines of...

NSDictionary *myNewDict = theTimer.userInfo; // I forgot the exact code off hand...

Open in new window

This thread contains some valuable information for you on this topic:


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now