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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:20:25+00:00 2026-05-13T13:20:25+00:00

In order to better understand the startup, event queue, and methods within my application

  • 0

In order to better understand the startup, event queue, and methods within my application I’m trying to write a program that does two things: Play a beep at the startup and every time the user hits a button. So far it only plays when the user hits the button. I know there may be multiple ways to get the startup beep to play, but in order to work with initialization code I want to do it by calling my beep method from within the applicationDidFinishLaunching method of the AppDelegate.m file.

Here is my code:

Log.h

#import <Cocoa/Cocoa.h>


@interface Log : NSObject {

    IBOutlet id button;

}
-(void)beepAndLog;
-(IBAction)buttonPressed:(id)sender;

@end

Log.m

#import "Log.h"


@implementation Log

-(void)beepAndLog {

    NSLog(@"The Method Was Called!");
    NSBeep();

}

-(IBAction)buttonPressed:(id)sender {

    [self beepAndLog];
}
@end

And the applicationDidFinishLaunching method looks like this:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
    [Log beepAndLog];

}

In the applicationDidFinishLaunching method, however, XCode warns me that

‘Log’ may not respond to ‘+beepAndLog’

and indeed, there is no beep and the log reads as follows:

MethodResponse[11401:a0f] +[Log
beepAndLog]: unrecognized selector
sent to class 0x100002100

(“MethodResponse” is the name of my project, btw)

I’m unsure why Log wouldn’t respond to beepAndLog, seeing as that’s one of its methods. Am I calling it incorrectly? I have a feeling this will be painfully obvious to you more experienced people. I’m a newbie. Any help would be appreciated! Thanks!

  • 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-13T13:20:25+00:00Added an answer on May 13, 2026 at 1:20 pm

    There are two possibilities. Either you defined beepAndLog as an instance method, when you wanted a class method, or you want to call it on an instance when you called it on the class.

    To change it to a class method, change the header to read:

    +(void)beepAndLog;
    

    and the implementation:

    +(void)beepAndLog {
        NSLog(@"The Method Was Called!");
        NSBeep();
    }
    

    For the other solution, make sure you have an instance of class Log around (probably a singleton), and do something like:

    [[Log logInstance] beepAndLog];
    

    from your notification method. The Log class would need to look something like this:

    Log.h:

    #import <Cocoa/Cocoa.h>
    
    @interface Log : NSObject {
        IBOutlet id button;
    }
    
    +(Log *)logInstance;
    
    -(void)beepAndLog;
    -(IBAction)buttonPressed:(id)sender;
    
    @end
    

    Log.m:

    #import "Log.h"
    
    Log *theLog = nil;
    
    @implementation Log
    
    +(Log *)logInstance
    {
        if (!theLog) {
            theLog = [[Log alloc] init];
            // other setup (like hooking up that IBAction)
        }
        return theLog;
    }
    
    -(void)beepAndLog {
        NSLog(@"The Method Was Called!");
        NSBeep();
    }
    
    -(IBAction)buttonPressed:(id)sender {
        [[Log logInstance] beepAndLog];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 340k
  • Answers 340k
  • 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 Look into the ISO/IEC 9899:1999, chapter 6.10.3.1. It states that:… May 14, 2026 at 4:46 am
  • Editorial Team
    Editorial Team added an answer You need to 'float' the third column as well. Then… May 14, 2026 at 4:46 am
  • Editorial Team
    Editorial Team added an answer self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"About" style:UIBarButtonItemStyleBordered target:self action:@selector(aboutB)] autorelease]; May 14, 2026 at 4:46 am

Related Questions

I'm working on creating a simple MCV application, in order to understand MVC better.
I am playing around with the garbage collector in C# (or rather the CLR?)
I am working on splitting out an existing, working application that I currently have
I'm basically trying to teach myself how to code and I want to follow
I'm quite new to this (understanding the WP Guts), and I wanted to understand

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.