setFrameAutosaveName:
フレームの自動保存名を指定した名前にセットします
- (BOOL)setFrameAutosaveName:(NSString *)frameNamefunc setFrameAutosaveName(_ frameName: String) -> Bool
解説
フレームの自動保存名を指定した名前にセットします。
もし、空の文字列(@"") をセットしたならば、フレームが変更されるたびにレシーバのフレームはユーザーデフォルト(saveFrameUsingName:で定義される)で保存されます。
nameをセットする事が出来ればYESを返し、アプリケーションで別のウインドウがその自動保存名を使っているならNOを返します。(レシーバの古い名前が残っている事もある)
返り値
(BOOL)
Bool
引数
オートセーブ名
Objective-C(NSString *)frameNameframeName: String
フレームワーク
ApplicationKit
クラス
NSWindow
使用可能
10.0
参照
+ removeFrameUsingName:
- stringWithSavedFrame
- setFrameFromString:
更新時のバージョン
OS X 10.10
関連記事(外部サイト)
例文
#import "Controller.h" @implementation Controller - (IBAction)pushButton:(id)sender { [myWindow setFrameAutosaveName:@"MainWindow"]; if ([myWindow setFrameUsingName: @"MainWindow" force:YES]){ NSLog(@"YES"); }else{ NSLog(@"NO"); } } @end
//NSWindow saveFrameUsingName //NSWindow setFrameUsingName //NSWindow frameAutosaveName() //NSWindow setFrameAutosaveName() //NSWindow removeFrameUsingName func buttonAction078_save(sender: AnyObject){ var aWindow : NSWindow = (sender as NSButton).window! aWindow.setFrameAutosaveName("")//自動保存中止 //NSWindow.removeFrameUsingName("window078") aWindow.saveFrameUsingName("window078") aWindow.title = "フレームを保存しました" } func buttonAction078_set(sender: AnyObject){ var aWindow : NSWindow = (sender as NSButton).window! if (aWindow.setFrameUsingName("window078")){ aWindow.title = "保存したフレームにしました" }else{ aWindow.title = "保存なし" } } func buttonAction078_auto(sender: AnyObject){ var aWindow : NSWindow = (sender as NSButton).window! aWindow.setFrameAutosaveName("window078") aWindow.title = "自動保存" NSLog("frameAutosaveName %@", aWindow.frameAutosaveName()!) } func buttonAction078_remove(sender: AnyObject){ var aWindow : NSWindow = (sender as NSButton).window! NSWindow.removeFrameUsingName("window078") aWindow.title = "フレームを保存をクリア" } @IBAction func function078(sender: AnyObject) { var theWindow : MyWindow078 = MyWindow078(contentRect: NSMakeRect(0.0, 0.0, 300, 200), styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask, backing: .Buffered, defer: false) windowArray.addObject(theWindow) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄 theWindow.center()//ウインドウをスクリーンの中心に theWindow.title = "フレーム未保存"//タイトル設定 theWindow.orderFront(self)//前面に theWindow.makeKeyAndOrderFront(self)//表示 theWindow.delegate = theWindow //ボタンを作成 var theButton1 : NSButton = NSButton(frame: NSMakeRect(0.0, 2.0, 70.0, 30.0)) theButton1.title = "Save" theButton1.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton1.action = Selector("buttonAction078_save:") theButton1.target = self theWindow.contentView.addSubview(theButton1) //ボタンを作成 var theButton2 : NSButton = NSButton(frame: NSMakeRect(70.0, 2.0, 70.0, 30.0)) theButton2.title = "Set" theButton2.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton2.action = Selector("buttonAction078_set:") theButton2.target = self theWindow.contentView.addSubview(theButton2) //ボタンを作成 var theButton3 : NSButton = NSButton(frame: NSMakeRect(140.0, 2.0, 70.0, 30.0)) theButton3.title = "auto" theButton3.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton3.action = Selector("buttonAction078_auto:") theButton3.target = self theWindow.contentView.addSubview(theButton3) //ボタンを作成 var theButton4 : NSButton = NSButton(frame: NSMakeRect(210.0, 2.0, 70.0, 30.0)) theButton4.title = "remove" theButton4.bezelStyle = NSBezelStyle.RoundedBezelStyle theButton4.action = Selector("buttonAction078_remove:") theButton4.target = self theWindow.contentView.addSubview(theButton4) }