亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

objective-c - Cocoa開發(fā)中怎樣獲得實例化的ViewController類?
天蓬老師
天蓬老師 2017-04-22 09:00:17
0
2
401

如圖,我在MainMenu.xib中拖入了一個Object,設定成我自己的mainMenuWindowController類,然后把界面元素的Outlet和Action綁定到里面。
程序運行的時候會加載這個nib,然后實例化里面的對象
現(xiàn)在我想在其他的類里面使用這個對象,我該如何從nib里獲取它呢?

天蓬老師
天蓬老師

歡迎選擇我的課程,讓我們一起見證您的進步~~

reply all(2)
左手右手慢動作

NSViewController* viewController = [[NSViewController alloc] initWithNibName:@"SomeNibName" bundle:nil];

小葫蘆

MainMenu.xib generally has an instance of AppDelegate. First declare an IBOutlet of MainWindowController in the header file of the automatically generated AppDelegate class, then go back to MainMenu.xib and connect the instance of MainWindowController (blue cube) to the IBOutlet just declared in AppDelegate.

Then, the rest of the code needs to access the instantiated MainWindowController, which can be done through the IBOutlet property or ivar of AppDelegate. Of course, access will not be effective until after -awakeFromNib.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template