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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:09:19+00:00 2026-05-26T23:09:19+00:00

lets say I have an NSWindow Class, that has several events for mouse and

  • 0

lets say I have an NSWindow Class, that has several events for mouse and trackpad movements
for example this code

IMHO, I think this should be good programming, it is similar to pointing an action of a button to its method in controller.
in MyWindow.m Class I have (which in IB I have set the window class to it)


@implementation MyWindow
- (void)swipeWithEvent:(NSEvent *)event {
NSLog(@"Track Pad Swipe Triggered");
/* I want to add something like this
   Note that, Appdelegate should be existing delegate, 
not a new instance, since I have variables that should be preserved*/
[AppDelegate setLabel];
}   
@end

and in My AppDelegate.h I have

@interface AppDelegate : NSObject <NSApplicationDelegate>
{
IBOutlet NSTextField *label;
}
-(void)setLabel;
@end

and in my AppDelegate.m I have

-(void)setLabel
{
[label setStringValue:@"swipe is triggered"];
}

I have tried #import @class, [[… alloc] init], delegate referencing in IB (I made an object class of MyWindow – thanks to the answer of my previous question )
that latter seems the closest one, it works if both of the classes are delegates, so I could successfully call the “setLabel” action from a button in a second controller (delegate class)’s IBAction method,
but this View Events seem not communicating with the delegate’s action although their code is executing.

  • 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-26T23:09:20+00:00Added an answer on May 26, 2026 at 11:09 pm

    You are sending a message to the AppDelegate class, not the instance of your AppDelegate class which is accessible from the NSApplication singleton ([NSApplication sharedApplication])

    [AppDelegate setLabel];
    

    This is wrong, to get the delegate do this:

    AppDelegate* appDelegate = (AppDelegate*)[[NSApplication sharedApplication] delegate];
    

    then send the message to that instance:

    [appDelegate setLabel];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have a class A that is fairly simple like this -
Lets say I have an ActionScript class: MyClass and that class has data in
Lets say we have this code: <div id='m1'> <div class=c></div> <div class=c></div> <div class=c></div>
Lets say have this immutable record type: public class Record { public Record(int x,
Lets say I have a div like this: <div id=test class=sourcecode> Some String </div>
Lets say I have object Tom which has class Person. Class Person String Name
Lets say i have a piece of code like this: test pattern | pattern
Lets say I have an enumerable source, that looks like this: IEnumerable<string> source =
Lets say we have the following code: class C t where g :: t
lets say i have this html code : <div> <a> <span id=a> </span> </a>

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.