macOS/iOS API解説

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

目次

compileAndReturnError:

Index>Foundation>NSAppleScript

アップルスクリプトオブジェクトをコンパイルします
-(BOOL)compileAndReturnError:(NSDictionary **)errorInfo:

解説

アップルスクリプトオブジェクトをコンパイルします。

返り値

( BOOL )

YES/NO

引数

( NSDictionary ** )errorInfo

エラー情報の辞書

クラス

NSAppleScript

Instance Methods

使用可能

10.2

参照

例文

#import "SetImage.h"

@implementation SetImage

- (IBAction)set:(id)sender
{
    //開けるファイル拡張子の配列
    NSArray      *imgTypes    = [ NSArray arrayWithObject : @"script" ];
    //OpenPanelを作る
    NSOpenPanel  *opPanel       = [ NSOpenPanel openPanel ];
    //Imageを作る
    NSAppleScript      *script;
    
    NSDictionary *error;
    //OpenPanelの結果のボタン番号
    int		  opRet;
     
        //OpenPanelでファイル選択   
    opRet = [ opPanel runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか
                                     file : @"Documents" //どのファイルを選択しておくか
                                    types : imgTypes ];//選べるファイルタイプ

    if ( opRet == NSOKButton ) {  // OPENPanelのボタンがOKなら
        //NSImageを作ってファイルから読み込む
        script = [ [ NSAppleScript alloc ] 
                          initWithContentsOfURL:
                          [NSURL fileURLWithPath:[opPanel filename]]
                          error:&error
                          ];
         if ([script compileAndReturnError:&error]){
         NSLog(@"YES");
         }else{
         NSLog(@"NO");
         }

    }
}

@end