Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3627580
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:54:23+00:00 2026-05-18T23:54:23+00:00

I am using CoreDateBooks and the Recipe samples as style guides, but also looking

  • 0

I am using CoreDateBooks and the Recipe samples as style guides, but also looking at many other samples and books. Can someone help explain how to correctly write the @selector statement? I see several different styles.

From CoreDataBooks, the add button selector is a single term with no colon, the method is an IBAction and it is declared in the interface.

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addBook)];
...
- (IBAction)addBook {
}

From Recipes, the add button selector is a term followed by a colon, the method uses (void) and (id)sender, and it is not declared in the interface.

UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)];
...
- (void)add:(id)sender {

Later in Recipes, the Cancel button has yet another syntax. The button selector is followed by a term with no colon, the method uses void but not sender, and again it is not declared in the interface.

UIBarButtonItem *cancelButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancel)];
...
- (void)cancel {

I understand that add and add: are different, with the second requiring a parameter, but is there a reason for one or the other? And when would I need to place the method name in the interface?

In other words, when I declare my own selector, such as @selector(add) or @selector(cancel), can I simply use the -(void) format and not place it in the interface?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:54:24+00:00Added an answer on May 18, 2026 at 11:54 pm

    IBAction is typedef’d to void. Its only function is to allow Interface Builder to map your interface elements to actions if your interface is in a nib file. It’s declared in your interface file only so Interface Builder can see it. Thus there’s no real difference between - (IBAction)myAction and - (void)myAction.

    If your action method doesn’t need to know what control/view triggered the action (i.e. it always does the same thing when the action is invoked on the target), you can omit the (id)sender parameter and pass in a selector without the colon.

    If you’re not using Interface Builder you don’t have to use the IBAction format, and if your methods will only be invoked within the same class then there’s no need to expose them in your header file (nor is there any harm in doing so).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Delphi 2010. I am looking for (possibly) a function or procedure which can
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using SQL Server 2008 R2 we are looking for a way to select the
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using jQuery, one can easily find out whether a particular element is visible using
Using Android TelephonyManager an application can obtain the state of data activity over the
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using WebViewBrush I can render web page content (it's screen shot) to e.g. Rectangle
Using PyGtk's IconView, I can set the icons to be reorderable by calling gtk.IconView.set_reorderable(True)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.