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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:29:51+00:00 2026-06-08T08:29:51+00:00

Im new to Objective-C & iOS programming so Im very confused about event and

  • 0

Im new to Objective-C & iOS programming so Im very confused about event and action handling. I don’t really understand what is the difference between connecting a button in Interface builder with its files owner method (for instance connecting button action pressed with my personal method buttonClicked) and on the other hand creating a delegate which will respond to button events? I am confused because I come from C# (.NET) and there you only handling events via delegation.

  • 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-08T08:29:54+00:00Added an answer on June 8, 2026 at 8:29 am

    Let’s create event handling programmatically first. Some assumptions …

    • you have class MyViewController
    • this class does contain property myButton (UIButton *)
    • you do want to handle events in this class

    First step is to create method to handle your button taps:

    -(void)onMyButtonTap:(UIButton *)sender {
      // My button was tapped, whoa, which one is in sender argument
    }
    

    Add tap event handling:

    -(void)loadView {
      [super loadView];
      [self.myButton addTarget:self action:@selector(onMyButtonTap:) forControlEvents: UIControlEventTouchUpInside];
    }
    

    What this code does? self in this case is instance of MyViewController class, which is going to handle touch up inside event (addTarget). action is method which will be called when UIControlEventTouchUpInside fires.

    So the addTarget:... line adds event handling and when the control event fires, this …

    [self onMyButtonTap:self.myButton];
    

    … will be called automatically.

    It’s simplified example, it can be more complicated in the real world:

    • you can have UIButton in separate UIView (good practice, I dislike when people put them in UIViewController)
    • you can handle multiple buttons taps in one method (distinguish between them by sender argument)
    • you can create more tap handling methods, one method for one button,
    • …

    And now back to outlets. Outlet is just an automatic glue for addTarget:....

    UIButton is subclass of UIControl and here you can see how other events can be handled and what events you can handle.

    Delegation is also common practice, but not for UIControl. There’s no delegate, etc. You have to do it in this way.

    Or you can enhance UIButton to handle events via blocks for example. Here’s one way https://gist.github.com/2468899 or you can Google for more.

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

Sidebar

Related Questions

I am quite new to Objective-C and Cocos2d, and i don't really understand why
I am very new to xcode & Objective-C (having come from PHP) i have
I am very new to programming and Objective-C and I am trying to work
Hey, Iam new to objective c and really dont know much about it. I
I'm new to iOS development and Objective-C programming so forgive my noobiness. Here's the
I am new to iOS development. I've recently stumbled upon the new objective-c collection-literals
I'm very new to objective C. I followed the tutorial for integrating Facebook to
I am Completely new to Objective C and Cocoa programming. Why does NSApplicationMain not
Recently I've begun to code in Objective-C for iOS 5 devices. My brand new
new to the Objective-C/iOS scene. Experienced in PHP and C++. I'm having a little

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.