macOS/iOS API解説

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

目次

directory

セーブパネルが持っている絶対パスを返します

解説

セーブパネルが持っている絶対パスを返します。

返り値

( NSString * )

絶対パス

引数

フレームワーク

ApplicationKit

クラス

NSSavePanel

Instance Methods

使用可能

10.0

参照

- setDirectory:

例文

#import "Controller.h"
//Localizable.stringsのJapaneseに "save_ok" = "保存するよ" としてUnicodeで保存してあります。
@implementation Controller
- (IBAction)pushButton:(id)sender
{
NSSavePanel *spanel = [NSSavePanel savePanel];
NSString *path = @"/Documents";
[spanel setDirectory:[path stringByExpandingTildeInPath]];
[spanel setPrompt:NSLocalizedString(@"save_ok",nil)];
[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){
            NSLog([savePanel directory]);
            }else{
            NSLog(@"Cansel");
            }
}
@end