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 8406857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:13:38+00:00 2026-06-09T23:13:38+00:00

So up until now i would just pass any parameter i need via the

  • 0

So up until now i would just pass any parameter i need via the buttons tag. However now i am using the tag already for something else so i need to be able to pass another string and a timer value with the tag to a void or action of some kind when you select the button.

This is my current button code for passing the buttons tag with to the action (below)

[mybtn addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside];

This is the void or action i am passing it to.

-(void)action:(UIButton*)btn{
NSLog(@"%d", [btn tag]);
}

So is there a way i can pass more than just the buttons tag (like a string) to the action? so i could have something like this.

-(void)action:(UIButton*)btn :myString{
NSLog(@"%d %@", [btn tag], myString);
}

Edit:
So now thanks to the suggestion my void looks like this

-(void)actionWithButton:(UIButton *)btn andString:(NSString *)myString{
NSLog(@"%d %@", [btn tag], myString);
}

But i still don’t know how to pass the myString parameter in the @selector part of the button.

  • 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-06-09T23:13:39+00:00Added an answer on June 9, 2026 at 11:13 pm

    You can add an UILable as a subView to that Button like

     UILabel *lblValue = [[UILabel alloc]initWithFrame:CGRectMake(0,0,0,0)];
     lblValue.tag=2;
     lblValue.text = myString;
     [objInputButton addSubview:lblValue];
    

    and you get your string in your Action method like below

      -(void)action:(UIButton*)btn
         {
         for(UILabel *lable in [btn subViews])
             {
                  if([lable tag]==2)
                       {
                             //get your string from lable
                       }
             }
         }
    

    Edit:-
    This answer by me is posted when I am starting my career, it is bad way of passing data even though it get works done, so, it is better to follow other answer posted by me.

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

Sidebar

Related Questions

I'm learning scheme and until now have been using guile. I'm really just learning
Until now I've been only writing console applications but I need to write a
Until now I've been used to using DAOs to retrieve information from databases. Other
Until now, I was debugging my PHP scripts and testcases using vim and the
Up until now I just put all my jQuery goodness inside the $(document).ready() function,
I'm a naughty programmer, and until now I haven't handled errors properly (e.g. just
Until now I've always used the ASP.NET MVC framework source for debugging ASP.NET MVC.
Until now I was logging the Error message and the stack trace of an
Up until now we used Ant in my company. Whenever we wanted to send
Up until now I used DateTime.Now for getting timestamps, but I noticed that if

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.