How to call an .m handler from ASOC?

Hello All,

I have a handler in the .m file and I want to fire it from my ASOC file.

I was trying this without success:

What I have:

#import “Reloader.h”

@implementation Reloader

  • (IBAction)menuAction:(id)sender {

#import <Cocoa/Cocoa.h>

@interface Reloader : NSObject

  • (IBAction)menuAction:(id)sender;


property myreloader: class "Reloader"
property apostolis: missing value

on callthem()
        set myreloader to apostolis's alloc()'s init()
        myreloader's menuaction()
   end callthem

but I get:
-[Reloader alloc]: unrecognized selector sent to instance 0x600000038160 (error -10000)


there are two options.

Either you add a blue cube in interface builder, set the class to Reloader and connect it to a “missing value” property,
then the object is already instantiated and you can use the instance methods directly.

Or you instantiate an object in code then you have to alloc/init the class or an variable containing the class object.

set classReloader to class "Reloader"
set myreloader to classReloader's alloc()'s init()

Thank you for your reply,

Although I feel stupid:

Option 1.
I dont understand what exactly I have to do. I have two blue cubes already, one is class Reloader and the second is class ASOC. I have an outlet in the ASOC called maction. Where I have to connect it? I tried to connect it to the Reloader but it doesn’t connect it with the handler menuaction.

Option 2.
How can I call the handler after that?

Option 1

in Interface builder select the nib file, then control-drag from the ASOC blue cube to Reloader blue cube and choose maction.

then write

maction's menuaction(me)

Option 2

set classReloader to class "Reloader"
set myreloader to classReloader's alloc()'s init()
myreloader's menuaction(me)

Could you make your method a class method? Then in ASOC you can call it but don’t have to alloc/init. Depends on what you need to do with the method of course.