Re: Properties being set to nil?


Dave
 

Hi Jon,

Thanks a lot!

I was just about coming to the same conclusion and was trying to figure out how to get the ViewController from the Window and then your message arrived.

That fixed it! All working well now!

Thanks again
Dave

On 16 Jan 2020, at 20:27, Jon Gotow <gotow@...> wrote:

Oh - there you go. Assuming that myGameWindowController is the parent window controller that manages myGameViewController, it will create an instance of your LTWMacGameViewController class when it loads. Calling [myStoryboard instantiateControllerWithIdentifier:kLTWGameMainViewControllerID] afterwards will create another instance of LTWMacGameViewController that's just floating in memory, not referenced by the window controller.

What you want to do is get the instance of LTWMacGameViewController that's managed by the window controller. Do this instead:

myGameViewController = myGameWindowController.contentViewController;

That'll fix it.

- Jon


On Jan 16, 2020, at 11:38 AM, Dave <dave@...> wrote:

//**
//** Instantiate the Game Window Controller
//**
myStoryboard = [NSStoryboard storyboardWithName:kLTWGameStoryboardName bundle:nil];
myGameWindowController = [myStoryboard instantiateControllerWithIdentifier:kLTWGameMainWindowControllerID];
if (myGameWindowController == nil)
{
return;
}

//**
//** Instantiate the Game View Controller
//**
myGameViewController = [myStoryboard instantiateControllerWithIdentifier:kLTWGameMainViewControllerID];
if (myGameViewController == nil)
{
return;
}



Join cocoa@apple-dev.groups.io to automatically receive all group messages.