モーダルウインドウを開く・閉じる
目次>
Mac
NSApplication.runModalForWindow()でモーダルウインドウを開く NSApplication.stopModal()としてNSWindow.orderOut(self)でモーダルウインドウを閉じる
//Modal windowの表示 //NSApplication runModalForWindow @IBAction func function008(sender: AnyObject) { //newWindowはNIBで作られているwindow //@IBOutlet weak var newWindow: NSWindow! let anApplication = MyApplication.sharedApplication() anApplication.runModalForWindow(newWindow) } //NSApplication stopModal @IBAction func function009(sender: AnyObject) { NSLog("%@",newWindow) let anApplication = MyApplication.sharedApplication() anApplication.stopModal() newWindow.orderOut(self) }
タプル
目次>
switch文で複数の値を使うことができたりする。
数値の代わりに _ を使うことができる。
範囲を示す場合は(-2...2, -2...2)のように...で表す。
バリューバインディング
//Value binding func function002() { let thePoint = (0, 2) switch thePoint { case (let x, 0): println("xに値が入っている。xの値は \(x)") case (0, let y): println("yに値が入っている。yの値は \(y)") case let (x, y): println("両方に値が入っている。 (\(x), \(y))") } }