macOS/iOS API解説

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

目次

selectorForCommand:

コマンドデスクリプタでセレクタを返します
-(SEL)selectorForCommand:(NSScriptCommandDescription *)commandDesc:

解説

コマンドデスクリプタでセレクタを返します。

返り値

( SEL )

アクションセレクタ

引数

( NSScriptCommandDescription * )commandDesc

コマンドデスクリプタ

クラス

NSScriptClassDescription

Instance Methods

使用可能

10.0

参照

- supportsCommand:

例文

// Apple Scriptコマンド
-(NSNumber *) retCommand:(NSScriptCommand *)sCommand
{
//スクリプトコマンド辞書
NSDictionary *dicWithNumber = 
    [NSDictionary dictionaryWithObjectsAndKeys:
    @"supp",@"AppleEventCode",
    @"NO",@"Optional",
    @"NSNumber<Int>",@"Type",nil];
NSDictionary *dicArguments = 
    [NSDictionary dictionaryWithObjectsAndKeys:
    dicWithNumber,@"withNumber",
    nil];
NSDictionary *diccomScriptControll = 
    [NSDictionary dictionaryWithObjectsAndKeys:
    @"Test",@"AppleEventClassCode",
    @"sadd",@"AppleEventCode",
    dicArguments,@"Arguments",
    @"NSScriptCommand",@"CommandClass",
    @"long",@"ResultAppleEventCode",
    @"NSNumber<Int>",@"Type",
    nil];
//スクリプトコマンド記述作成
NSScriptCommandDescription *scomd = 
    [[NSScriptCommandDescription alloc]
        initWithSuiteName:@"test"
        commandName:@"ScriptControll"
        dictionary:diccomScriptControll
        ];
        
//スクリプトクラス辞書
    NSDictionary *dicToOneRelationships = 
        [NSDictionary dictionary];
    NSDictionary *dicToManyRelationships = 
        [NSDictionary dictionary];
    NSDictionary *dicSupportedCommands = 
        [NSDictionary dictionaryWithObjectsAndKeys:
        @"retCommand:",@"test.ScriptControll",
        nil];
    NSDictionary *dicInverseRelationships = 
        [NSDictionary dictionary];
        
        NSDictionary *dicSource = 
            [NSDictionary dictionaryWithObjectsAndKeys:
            @"Myou",@"AppleEventCode",
            @"NO",@"ReadOnly",
            @"NSNumber<Int>",@"Type",nil];
    NSDictionary *dicAttributes = 
        [NSDictionary dictionaryWithObjectsAndKeys:
        dicSource,@"source",
        nil];
NSDictionary *dicScriptControll = 
    [NSDictionary dictionaryWithObjectsAndKeys:
    dicToOneRelationships,@"ToOneRelationships",
    dicToManyRelationships,@"ToManyRelationships",
    dicSupportedCommands,@"SupportedCommands",
    @"NSCoreSuite.AbstractObject",@"Superclass",
    dicInverseRelationships,@"InverseRelationships",
    dicAttributes,@"Attributes",
    @"MyOb",@"AppleEventCode",
    nil];
//スクリプトコマンド記述作成
NSScriptClassDescription *scd = 
    [[NSScriptClassDescription alloc]
        initWithSuiteName:@"test"
        className:@"MyObject"
        dictionary:dicScriptControll
        ];
        
        
NSNumber * number = (NSNumber *)[[sCommand evaluatedArguments] 
                                                objectForKey:@"withNumber"];
                            
//NSLog([scd description]);
NSLog(NSStringFromSelector([scd selectorForCommand:scomd]));

		return number;
	}