macOS/iOS API解説

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

目次

AutoreleasingUnsafeMutablePointer<NSArray?>

var windowArray : NSMutableArray = []   //ウインドウ保持用
    
    @IBAction func function001(sender: AnyObject) {
        if (windowArray.count == 0 ) {
            let nib : NSNib = NSNib(nibNamed: "NewWindow", bundle: NSBundle.mainBundle() )!
            //var topLevelArray : NSArray = []
            var topLevelArray = NSMutableArray()
            let outputValue = AutoreleasingUnsafeMutablePointer<NSArray?>(&topLevelArray)
         
            //NSBundle.mainBundle().loadNibNamed("NewWindow", owner: nil, topLevelObjects: outputValue)
            if let result : Bool = nib.instantiateWithOwner(self, topLevelObjects: outputValue) where result {
                for name in topLevelArray {
                    if ((name as! NSObject).className == NSWindow.className() ){
                        NSLog("%@",name.description)
                        NSLog("%@",(name as! NSWindow).title)
                        
                        let theWindow : NSWindow = (name as! NSWindow)
                        windowArray.addObject(theWindow) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄
                        
                        (name as! NSWindow).makeKeyAndOrderFront(self)
                        (name as! NSWindow).orderFront(self)//前面に
                        //(name as! NSWindow).makeKeyAndOrderFront(self)//表示
                    }
                }
            }
            outputValue.memory = nil
        }
    }