macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

setEventHandler:andSelector:forEventClass:andEventID:

イベントハンドラを登録します
-(void)setEventHandler:(id)handler:
     andSelector:(SEL)sel:
     forEventClass:(AEEventClass)eventClass:
     andEventID:(AEEventID)eventID:

解説

イベントハンドラを登録します。
他のアプリケーションにイベントを送るためには使用することはできません。
AEEventClassやAEEventIDの定数はCarbonにあります

返り値

( void )

なし

引数

( id )handler

イベントハンドラ

( SEL )sel

アクションセレクタ

( AEEventClass )eventClass

イベントクラス

( AEEventID )eventID

イベントID

クラス

NSAppleEventManager

Instance Methods

使用可能

10.0

参照

例文

#import "Controller.h"

@implementation Controller

- (IBAction)pushButton:(id)sender
{
NSAppleEventManager *aeMgr;
aeMgr = [NSAppleEventManager sharedAppleEventManager];

[ aeMgr setEventHandler:self
        andSelector:@selector(handleAppleEvent:withReplyEvent:)
        forEventClass:kASAppleScriptSuite
        andEventID:kASCommentEvent 
        ];

}

- (void)handleAppleEvent:(NSAppleEventDescriptor *)inEvent
    withReplyEvent: (NSAppleEventDescriptor *)outReplyEvent

{
NSLog(@"!!!");
}

@end