I have installed lately XCode 4+, and since on I get warning message ‘window’ is deprecated.
I have subclassed NSView and called it CentralView and used it to load various views dynamically. I had to subclass the NSView, because there are methods I needed to override.
In other class that controls loading central views I have created following method:
- (IBAction)showUserInfoView:(id)sender{
NSLog(@"Load new user info page");
// Try to end editing
NSWindow *w = [centralView window]; // Here I get warning 'window' is deprecated
BOOL ended = [w makeFirstResponder:w];
if (!ended) {
NSBeep();
return;
}
// Put the view in the box
NSView *v = [[viewControllers objectAtIndex:0] view];
NSArray* viewSet = [NSArray arrayWithObject: v];
[centralView setSubviews: viewSet];
}
As far as I am aware the window method in NSView is up to date. Why do I get message?
What type is
centralView? What happens if you say[(NSView*)centralView window]?It’s possible that the compiler is not finding
-[NSView window], but some other-windowmethod which is deprecated. IfcentralViewis declared as anidthen the compiler doesn’t know it’s anNSViewand has to guess.