sendAction:to:from:
ターゲットにメッセージを送信します
- (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)sender
func sendAction(_ anAction: Selector, to aTarget: AnyObject?, from sender: AnyObject?) -> Bool
解説
ターゲット(aTarget)にメッセージ(anAction)を送信します。
引数
( SEL )anAction
_ anAction: Selector
( id )aTarget
to aTarget: AnyObject
ターゲット
( id )sender
from sender: AnyObject?
送信オブジェクト
フレームワーク
ApplicationKit
クラス
NSApplication
使用可能
10.0
編集時のバージョン
10.10
参照
- targetForAction:
- tryToPerform:with:
- makeWindowsPerform:inOrder:
例文
#import "Controller.h" @implementation Controller - (IBAction)pushButton:(id)sender { [NSApp sendAction:@selector(theAction:) to:self from:sender ]; } -(void)theAction:(id)sender { NSLog([sender className]); } @end
//NSApplication sendAction:to:from: @IBAction func function056(sender: AnyObject) { //共有アプリケーションインスタンスを取得 let anApplication = MyApplication.sharedApplication() //このインスタンスの関数function054:を動かしてみる var result:Bool = NSApp.sendAction(Selector("function054:"), to: self, from: self) (Selector("function054:"), with: self ) //結果 if (result){ NSLog("function056 true") }else{ NSLog("function056 false") } }