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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:40:51+00:00 2026-05-20T16:40:51+00:00

I have two class .. in one of them I am using six buttons

  • 0

I have two class ..

in one of them I am using six buttons with their tag..

like this

[btnF1 setTag:1];

and I am using this tag

like this..

- (void)showPhoto:(UIButton*)btnSender       {    
    NSLog(@"showPhoto:%d",btnSender.tag);   
}  

Now I want to make variable that stores the value of btnSender.tag and I can also use that value in any other class also…

I made two approches..
1) I made a variable in this class which stores btnSender.tag value and I tried to use this value in other class but it is giving me null

2) I tried out the global variable but not able to see the value of the global variable in the NSLog..

I am not using IB

Help me out…:)

  • 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-20T16:40:52+00:00Added an answer on May 20, 2026 at 4:40 pm

    You can use NSUserDefaults or UILabel to store the value of button tag. But for using UILabel you will have to Outlet it to a hidden label in your XIB only then it will retain its value.

    NSUserDefaults stores the value permanently till you refresh it. So there won’t be a problem of retaining the values.

    So better approach is to use NSUserDefaults as shown below. May be you can put this on an event (for Example ButtonClick if you are going to next view on a button click.)

    NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults]; 
    [userDef setObject:[NSString stringWithFormat:@"%d",btnSender.tag] forKey:@"BtnTag"];
    

    Now when you go to next view, you can access it using below code:

    int tagValue = [[[NSUserDefaults alloc] valueForKey:@"BtnTag"] intValue];
    

    Hope this helps you.

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

Sidebar

Related Questions

I have two lists of objects, using Linq I would like to merge them,
I have two classes, and want to include a static instance of one class
I have two Java interfaces and one implementing class. (I have used Eclipse to
I have two tables, one Company and one Employee: class Company(models.Model): name = models.CharField(max_length=60)
Let's say I have two models, Classes and People. A Class might have one
I have two models related one-to-many: a Post and a Comment : class Post(models.Model):
I have two different projects and in one, I have a class that defines
I have two solutions, one is a class library and the other is a
I have these two methods on a class that differ only in one method
I have two classes in a many-to-many relationship, but only one of them have

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.