writeRTFDToFile:atomically:
指定したパスにテキストオブジェクトのデータをRTFDファイルとして書き出します
-(BOOL)writeRTFDToFile:(NSString *)path: atomically:(BOOL)atomicFlag:
解説
指定したパスにテキストオブジェクトのデータをRTFDファイルとして書き出します。
成功すればYESを返します。
【atomicFlag】
YESをセットすると、上書きする場合に一旦別のファイルに書き出してからファイル名を変更するので、書き出し中にエラーが起こっても元のファイルは残っている状態になります。
NOをセットすると、直接上書きします。
返り値
( BOOL )
書き出せたかYES/NO
引数
( NSString * )path
書きだすパス
( BOOL )atomicFlag
安全に書くか
フレームワーク
ApplicationKit
クラス
NSText
Instance Methods
使用可能
10.0
参照
- RTFFromRange:
- RTFDFromRange:
- readRTFDFromFile:
例文
#import "Controller.h" @implementation Controller - (IBAction)pushButton:(id)sender { NSSavePanel *spanel = [NSSavePanel savePanel]; [spanel setRequiredFileType:@"rtfd"]; [spanel beginSheetForDirectory:NSHomeDirectory() file:nil modalForWindow:myWindow modalDelegate:self didEndSelector:@selector(didEndSaveSheet:returnCode:conextInfo:) contextInfo:NULL]; } -(void)didEndSaveSheet:(NSSavePanel *)savePanel returnCode:(int)returnCode conextInfo:(void *)contextInfo { if (returnCode == NSOKButton){ [myOutlet writeRTFDToFile:[ savePanel filename ] atomically:YES]; NSLog(@"OK"); }else{ NSLog(@"Cansel"); } } @end