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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:44:02+00:00 2026-05-17T14:44:02+00:00

I have a button in my App called myButton, what I what to do

  • 0

I have a button in my App called myButton, what I what to do is really simple. I want to have an integer that adds one to itself every time the Button is pushed. Here’s what the code looks like right now:

- (IBAction)myButton {  
NSLog(@"Button was pushed WOHHOP");
}

This is inside my .m file, so do I need to declare an integer inside my .h file? I just want to Log the value of it inside this button action so that as I push it I can see the number increase by one every time.

Any advice would help,
Thank you!

  • 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-17T14:44:02+00:00Added an answer on May 17, 2026 at 2:44 pm

    i would use an instance variable by default:

    @interface MONClass : MONSuperClass
    {
        NSUInteger clicks;
    }
    
    @end
    
    @implementation MONClass
    
    - (id)init {
        self = [super init];
        if (0 != self) {
            clicks = 0;
        }
        [return self];
    }
    
    - (IBAction)myButton:(id)sender
    {
    #pragma unused(sender)
        ++clicks;
        NSLog(@"Button was pushed %i times WOHHOP", clicks);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm now testing GKPeerPickerController. I have a simple app that just have a button
What I am want to do is really simple. I have an gwt app
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
I have a button in my Cocoa app that opens a url in the
I have a button that launches the google maps app on my device via
I have placed an Image as a button in my App and I want
I have an app that crashes if i press the home button, back button
I have an app that when I click a button loads a new TabItem
I have a simple metro app contains a button, a label and a drop
In my app, I have a button called EXIT , when the user clicks

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.