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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:30:03+00:00 2026-05-15T22:30:03+00:00

When setting the method of a button call or adding an event listener in

  • 0

When setting the method of a button call or adding an event listener in objective-c, one normally sets the target to self. However I have a subclass of NSObject named CALLS, separate from the main file. This subclass has a void called METHOD_NAME which should be executed.

THe first question is would the void be
+(void)METHOD_NAME

or

-(void)METHOD_NAME
in the subclass.

The next is how would I set the target of the addEventListener to use the subclass of NSObject and call the method within it. Would I do

target:[CALLS class];

or create an instance of the subclass of NSObject(calls) and then pass that?

  • 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-15T22:30:04+00:00Added an answer on May 15, 2026 at 10:30 pm
    • “CALLS” and “METHOD_NAME” are not good names for a class and method. Try to follow the Objective-C conventions. Since you are “nonono”, you might call your class something like NNEventListener and the method buttonTapped, for example.

    • First question: it actually doesn’t matter. Class methods (+) and instance methods can both be used. However, it would be very unusual to not use an instance method for listening to UI events, so the answer is, use -(void)buttonTapped

    • Second question: I don’t think there is a method in all of Cocoa called addEventListener. Where did you hear about that? Have you been using web frameworks to make apps before?

    To add a target to a button (or any other UIControl), you use -addTarget:action:forControlEvents: To get a reference to the method that you want to be called, you use the special @selector directive like this:

    [aButton addTarget:anObject action:@selector(buttonTapped) forControlEvents:UIControlEventTouchUpInside];
    

    aButton — your button
    anObject — any object. self is just the object that the method belongs to. You can pass in any object at all
    buttonTapped — the name of the method that should be called when the button is tapped

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

Sidebar

Ask A Question

Stats

  • Questions 467k
  • Answers 467k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In your settings.xml file, you'll want under <w:settings/> an element… May 16, 2026 at 1:54 am
  • Editorial Team
    Editorial Team added an answer What I think is tripping you up is the fact… May 16, 2026 at 1:54 am
  • Editorial Team
    Editorial Team added an answer I somehow must have missed the link in the documentation… May 16, 2026 at 1:53 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.