Window not opening using Documents

Hi all,
I am reading Chapter 9 and I am finding that when I run the RaiseMan app, no window is being displayed when I run it. I need to click on the icon in the dock. I also found by running the downloadable code for raiseMan, I see the same thing. I am missing something or should the window appear automatically when running the app (without having to click on the icon in the doc or using File > New)?
Thanks
Paul

This is a pretty common annoyance. Our best guess is that it’s something involving how Xcode interacts with state restoration and the document system. You should find that if you run the application outside of Xcode it behaves as expected (creating a new empty document if one was not already open).

Some of the apps I run in Xcode don’t run properly either, and I find that if I run the app using Xcode, then quit the app using the Menu Bar: AppName>Quit AppName as opposed to quitting using Xcode’s stop button, then the next time I run the app, the app runs correctly. I dunno if that will help you.

Thanks - I found running it outside of Xcode worked as expected.
Paul

How do you run an app outside of Xcode?

Got it: In Xcode, look in the Products group(folder), and you should see the file RaiseMan.app. Right click on RaiseMan.app, and select Show in Finder. Then click on RaiseMan.app in Finder.

I verified that starting RasieMan.app outside of Xcode does indeed show the window. I’m wondering, Adam, if this truly is a bug in Xcode, if Apple have been notified. I’m not up to the latest yet - I’m at MacOSX 10.11.6 and Xcode 8.1, but before I even found this particular conversation I had realized that “Oh - this is a Document App - I need to create a new document”, so once I launched the app I found I was indeed able to use File -> New to get a new window to show. As for me, this is my first time posting - I’ve found this forum to be invaluable in navigating through the issues dealing with changes in Xcode and with Swift 3. But I certainly would buy a 6th edition of the book if/when it came out …

No joy
The point at which the window stops opening is setting the binding of the NSArrayController to “File’s Owner” and the KeyPath to “employees”

But it came back if I prefaced the declaration for employees with @objc
The class declaration needs @objc for the class and variables as well and the variables should be Dynamic.

This solution worked for me in Xcode 11.

@objc
var employees: [Employee] = []
1 Like