0

After some 'cleaning' of a working app, the main window appears as designed in the MainWindow.xib.

  • I deleted a MainWindowViewController object in IB. (was beneath Font Manager)
  • MainWindow.xib has it's Custom class set to MainWindowViewController
  • The table uses Content Mode - View Based
  • The two required methods ARE included in that implementation file
  • included in header file
  • Table view connection has been made to File's Owner

EDIT: Does the full error message give a clue? Why the NSApplication?

*** Illegal NSTableView data source (<NSApplication: 0x100607ad0>).

What am I missing? What should I check to resolve?

Image included to help visualize.

Screenshot of MainWindow.xib

EDIT 2: (New info)

I deleted the data source & delegate connection from the table view and the error disappeared. The same IB designed window opens with an empty table view.

David
  • 3,285
  • 1
  • 37
  • 54
  • dont make the application the tableView's data source, that is bad form, it will make it hard to expand later, make a special class (or something that you already have that will always be in 1:1 relationship with the table or the tables data) for it, and make it adopt the appropriate data source protocol. – Grady Player Aug 27 '13 at 15:19
  • Did you also declare the NSTableView DataSource protocol in your .h file that is both file's owner in your nib and the class implementing the DataSource methods? – uchuugaka Aug 27 '13 at 15:21
  • @uchuugaka Yes. Thank you. I forgot to include that in description. – David Aug 27 '13 at 15:25
  • @GradyPlayer I don't understand, but don't think I did (intentionally) set data source to application. The dark window above is for File's Owner. When I check connections for Application, it has only one received action, Terminate. No outlets. What do you mean? (Protocol has always been in .h file) – David Aug 27 '13 at 15:29
  • sorry I was making assumptions that you hadn't set it up correctly... we will need more error than what you have provided, perhaps a sample project, your version of xcode etc. (if this is a bug in a developer preview release of xcode try it in a stable version) – Grady Player Aug 27 '13 at 18:44
  • @GradyPlayer Thanks. I asked the question because I'd run out of ideas to try to debug this issue. At this point, I've decided to re-build the main window and it's controller, start from scratch and see if it works. (It is in Xcode DP and may well be a bug) – David Aug 27 '13 at 23:15
  • Hmm, it sure looks like the data source is set to the application, both in the screenshot and in the error message. By default, MainMenu.xib's File's Owner is the application, not the app delegate. You have the app delegate instantiated as a separate object in the sidebar -- maybe try connecting the outlets to that instead? – Siobhán Aug 30 '13 at 08:10

1 Answers1

0

My 'project' is more complicated than the documentation covers. How to add a Window Controller to the Cocoa/Core Data template and utilize this controller is not easily found.

The most pronounced symptom was that the code in the intended controller was not being executed. The 2 required delegate methods were present. awakeFromNib wasn't being called either.

After more research, it appears the 'missing link' is the (previously deleted) NSObject set to the custom class of MainWindowViewController or MainWindowController in the nib file. I'm still looking for why this needs to be or why connecting to the File's Owner doesn't make the connection.

On the one hand, we can set the File's Owner to the custom class (MainWindow)ViewController or (Main)WindowController and connect the contained views to File's Owner. This doesn't work as I expected.

On the other hand, (apparently correct) we can add an NSObject to the MainMenu.xib file, set it's custom class to the (MainWindow)ViewController or (Main)WindowController and then connect outlets to the subviews to this object. The step of adding this object in IB is the only way I could find of connecting the window to the controller.

David
  • 3,285
  • 1
  • 37
  • 54