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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:48:56+00:00 2026-06-02T21:48:56+00:00

I try to understand a few things in Cocoa but I got stuck on

  • 0

I try to understand a few things in Cocoa but I got stuck on one thing. I’m following Minimalistic Cocoa Programming, there it is a NSMenuItem responsible for terminating the app. Now, I would like to create another NSMenuItem, with a shortcut, that when pressed, it NSLog-s something. But I don’t know where should I put the implementation of said selector? Should I subclass the whole NSApplication? Should I setDelegate to some NSObject instance, acting as a controller?

  • 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-02T21:49:00+00:00Added an answer on June 2, 2026 at 9:49 pm

    You need to create a class that can be used as the target of the menu item. Something like this:

    @interface Tester : NSObject
    @end
    @implementation Tester
    - (void)logTest:(id)sender
    {
        NSLog(@"Test");
    }
    @end
    

    Then set it as the target:

    id testMenuItem = [[[NSMenuItem alloc] initWithTitle:@"Log Test" action:@selector(logTest:) keyEquivalent:@"l"] autorelease];
    id tester = [[[Tester alloc] init] autorelease];
    [testMenuItem setTarget:tester];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

there is one think, i can't understand anyway:((( when i try to set cookie(it
I try to understand the memory management in ObjectiveC and still some things are
I'm new to win32 API programming and I try to understand source code of
I can fix the below exception with a try-catch loop but I cannot understand
From http://fullthrottledevelopment.com/php-nonce-library#download , there is a PHP nonce library, but there are a few
I have been coding in iphone platform for about a few months. One thing
There are a few other questions about this error, but I'm having a hard
I've been a programmer for a few years now but want to try and
I'm trying to understand the basics of practical programming around character encodings. A few
I try to learn Rspec , but I don't understand what is that. Let

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.