Re: Properties being set to nil?


Jon Gotow
 

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@looktowindward.com> 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.