I have an App with an NSWindowController and an associated XIB which is not needed most of the time (admin interface window), so I wanted to use Lazy instantiation. However, I also need to setup the 'delegate' and that is when the errors happen.
I have everything setup in the AdminWindow,h (subclass of `NSWindowController') and .m file.
In my main controller, MainController (subclass of NSObject) I have the following working code.
@interface MainController : NSObject<AdminWindowDelegate>{
   AdminWindow *myAdminWindow;
}
@implementation MainController
-(id)init{
  myAdminWindow = [[AdminWindow alloc] init];
  [myAdminWindow setDelegate:self];
}
-(IBAction)openAdminWindow:(id)sender{
 [myAdminWindow showWindow:nil];
}
So that all works, but I don't want to instantiate myAdminWindow until it's needed, thought lazy instantiation would work.
Altered the MainController:
 @implementation{
 -(AdminWindow *) myAdminWindow{
 if(!_myAdminWindow){
 _myAdminWindow = [[AdminWindow alloc] init];
 //Tried to set delegate here, but does not work
}
-(IBAction)openAdminWindow:(id)sender{
 [self.myAdminWindow showWindow:nil];
}
Where do I set the delegate? I tried just after 'alloc' 'init' of myAdminWindow, but it does not work. when I start typing the command
 _myAdminWindow.setDe...  Xcode gives nothing, .setDelegate or .delegate are not options.
I've tried
 [_myAdminWindow setDelegate   Nope, does not work either.
Leaving out the delegate portion, everything else works as desired.
Question: When using lazy instantiation , where do I set the delegate? and how?
Thank you in advance
===[EDIT]===
In case someone else has the same question.
Thank you to Phillip Mills for the reply and reminder.
I removed the following declaration in @interface of MainController:
 AdminWindow *myAdminWindow;
And declared myAdminWindow in the MainController's interface section as a property - and all is good!
 
    