macOS/iOS API解説

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

目次

setPrompt:

「OK」ボタンのタイトルをセットします
-(void)setPrompt:(NSString *)prompt:

解説

「OK」ボタンのタイトルをセットします。
ローカライズされた文字列を使うことで、他言語対応ができます。
初期状態では、セーブパネルでは「保存」、オープンパネルでは「開く」となっています。
ボタンのサイズは変更できません。

返り値

( void )

なし

引数

( NSString * )prompt

プロンプト

フレームワーク

ApplicationKit

クラス

NSSavePanel

Instance Methods

使用可能

10.0

参照

- prompt

例文

#import "Controller.h"
//Localizable.stringsのJapaneseに "save_ok" = "保存するよ" としてUnicodeで保存してあります。
@implementation Controller
- (IBAction)pushButton:(id)sender
{
NSSavePanel *spanel = [NSSavePanel savePanel];
NSBundle *bundle;
NSString *save_ok;
        bundle = [NSBundle mainBundle];
        save_ok = [bundle localizedStringForKey : @"save_ok"
                                    value:nil
                                    table:nil];
//NSLocalizedStringを使う方法もあります。
[spanel setPrompt:save_ok];
[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 accessoryView] className]);
}else{
NSLog(@"Cansel");
}
}
@end