richTextSource
ソーステキストを属性付き文字列で返します
解説
ソーステキストを属性付き文字列で返します。
返り値
( NSAttributedString * )
引数
フレームワーク
ApplicationKit
クラス
NSAppleScript Additions
Instance Methods
使用可能
10.0
参照
例文
#import "SetImage.h" @implementation SetImage - (IBAction)set:(id)sender { //開けるファイル拡張子の配列 NSArray *imgTypes = [ NSArray arrayWithObject : @"script" ]; //OpenPanelを作る NSOpenPanel *opPanel = [ NSOpenPanel openPanel ]; //アップルスクリプトオブジェクトを作る NSAppleScript *script; NSAttributedString *aString; 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 ]; [image lockFocus]; [[script richTextSource] drawAtPoint:NSMakePoint(50,50)]; [image unlockFocus]; NSLog([NSString stringWithFormat:@"%d",error]); } } @end