macOS/iOS API解説

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

目次

isOptionalArgumentWithName:

指定した引数を持つかを返します
-(BOOL)isOptionalArgumentWithName:(NSString *)argument:

解説

指定した引数を持つかを返します。

返り値

( BOOL )

YES/NO

引数

( NSString * )argument

引数名

クラス

NSScriptCommandDescription

Instance Methods

使用可能

10.0

参照

- argumentNames

例文

// 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 *dicScriptControll = 
    [NSDictionary dictionaryWithObjectsAndKeys:
    @"Test",@"AppleEventClassCode",
    @"sadd",@"AppleEventCode",
    dicArguments,@"Arguments",
    @"NSScriptCommand",@"CommandClass",
    @"long",@"ResultAppleEventCode",
    @"NSNumber<Int>",@"Type",
    nil];
//スクリプトコマンド記述作成
NSScriptCommandDescription *scd = 
    [[NSScriptCommandDescription alloc]
        initWithSuiteName:@"test"
        commandName:@"ScriptControll"
        dictionary:dicScriptControll
        ];
NSNumber * number = (NSNumber *)[[sCommand evaluatedArguments] 
                                                objectForKey:@"withNumber"];

NSScriptCommand *sc = [scd createCommandInstance];  

([[sc commandDescription] isOptionalArgumentWithName:@"withNumber"])?NSLog(@"withNumber YES") : NSLog(@"withNumber NO");
		return number;
	}