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

  • Home
  • SEARCH
  • 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 836657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:01:09+00:00 2026-05-15T05:01:09+00:00

// Original // I want to call this guy -(void)addFavorite:(NSString *)favoriteToAdd at, @selector here

  • 0

// Original //

I want to call this guy

-(void)addFavorite:(NSString *)favoriteToAdd

at, @selector here

action:@selector([addFavorite favoriteToAdd:@"string"])];

But I keep getting syntax error no matter which way I write it.

Can someone point out the appropriate way to call this function? When it had no parameter and was “addFavorite,” it worked fine.

// Update //

I apologize for not being more specific. This is an iphone application. I have a view with a button, when the button is pressed, an NSString is grabbed and passed to addFavorite (function above). I get syntax errors when attempting to add a parameter to addFavorite.

I want to call the following addFavorite

-(void)addFavorite:(NSString *)favoriteToAdd

Something like this

    UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
                              initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
                              target:self
                              action:@selector([addFavorite: favoriteToAdd:@"testString"])];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];

error: Expected ‘:’ before ‘[‘ token

  • 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-15T05:01:10+00:00Added an answer on May 15, 2026 at 5:01 am

    [obj action:@selector(addFavorite:) withObject:@"string"]

    Edit: can’t spell today 🙂

    One of the methods for calling selector on button click:

    [buttonObj target:self action:@selector(addFavoriteClick)]`
    

    You’ll then have to PULL the string in addFavoriteClick from where it’s defined and pass it into addFavorite:

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

Sidebar

Related Questions

I have an image (let's call it original image ) on which I want
I have this main JFrame (call it DrinkChooser) that shows another complex confirmation JFrame
So I want to know if this is a good idea or a bad
My problem is that I want to execute a python file with an argument
I have a Panel I want to fill with some UserControl(s) at runtime. These
I have a boost::variant , which contains various types and I have a string
I want to get all properties of an object during runtime and save it
Problem Given a set of known cartesian points (set A), and a 2d transformation
I'm using asp mvc 2 and I have a page which has some data
Let's say I have an ASP.NET MVC webapp that calls a repository layer, which

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.