Я использовал этот код для настройки окна. Он работал раньше.Почему мое окно загружается каждый раз, когда я получаю доступ к `self.window`
- (void)awakeFromNib
{
NSLog(@"self = %p", self);
[(NSPanel *)self.window setWorksWhenModal: NO];
}
Во всяком случае, каждый раз, когда я достигаю self.window
окно загружается из кончика пера. Это проблема здесь, потому что она делает это рекурсивным. но это проблема и в других местах, так как каждый раз я получаю другое окно!
От "NSWindowController":
/* The window getter will load the nib file (if there is one and it has not yet been loaded) and then return the window.
If it has to load the window, it will first call -windowWillLoad, then -loadWindow, then -windowDidLoad.
To affect nib loading or do something before or after it happens, you should always override those other methods.
The window setter is used internally from -initWithWindow: or when a controller's nib file is loaded (as the "window" outlet gets connected).
You can also call it yourself if you want to create the window for a window controller lazily, but you aren't loading it from a nib.
This can also be used to set the window to nil for cases where your subclass might not want to keep the window it loaded from a nib, but rather only wants the contents of the window.
Setting the window to nil, after the nib has been loaded, does not reset the -isWindowLoaded state.
A window controller will only load its nib file once. This method makes sure the window does not release when closed, and it sets the controller's -windowFrameAutosaveName onto the window and updates the window's dirty state to match the controller's document (if any).
It also calls -setWindowController: on the window. You can override this if you need to know when the window gets set, but call super.
*/
@property (nullable, strong) NSWindow *window;
О, это было именно оно. У меня был объект контроллера в окне NIB! Спасибо! – netigger
Или подожди, позволь мне проверить это снова .. Просто воссоздал его, а теперь нет объектов в NIB, но все равно получай его, я не могу вернуться. – netigger
У меня на самом деле была проблема. Но я все еще обращался к 'self.window' из awakeFromNib, но, похоже, теперь работает хорошо, что я удалил это также – netigger