Re: NSWindow reference remains null after window did load (SOLVED)
No, the syntax was right. The problem mysteriously disappeared when I altered the timing of the method to redraw the table, including the time data is loaded. Thanks for your suggestions. On Jul 28, 2009, at 8:38 PM, Andy Lee wrote: Just to be sure -- your method is numberOfRowsInTableView:, not numberOfRowsInTableView, right? You mentioned you'd tried copying working method declarations, so I suspect that's not the problem, but I figured I'd double-check just in case *you* were calling it somewhere you'd forgotten about and it wasn't the table view that was calling it. There was a similar mystery within the past few months, with very similar "impossible" symptoms. I believe the solution was a missing call to reloadData. But this doesn't sound like your problem, because if numberOfRowsInTableView: returns 17, then the value- getter method should have gotten called 17 times for each column. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
Just to be sure -- your method is numberOfRowsInTableView:, not numberOfRowsInTableView, right? You mentioned you'd tried copying working method declarations, so I suspect that's not the problem, but I figured I'd double-check just in case *you* were calling it somewhere you'd forgotten about and it wasn't the table view that was calling it. There was a similar mystery within the past few months, with very similar "impossible" symptoms. I believe the solution was a missing call to reloadData. But this doesn't sound like your problem, because if numberOfRowsInTableView: returns 17, then the value-getter method should have gotten called 17 times for each column. --Andy On Tuesday, July 28, 2009, at 04:12PM, "Daniel Child" wrote: >The correct number, a value obtained from the model. > >On Jul 28, 2009, at 3:02 PM, cocoa-dev-requ...@lists.apple.com wrote: > >>> The only datasource method to get called is numberOfRowsInTableView. >> >> What number is it returning? >> >> --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
The correct number, a value obtained from the model. On Jul 28, 2009, at 3:02 PM, cocoa-dev-requ...@lists.apple.com wrote: The only datasource method to get called is numberOfRowsInTableView. What number is it returning? --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
On Jul 28, 2009, at 11:04, Daniel Child wrote: The only datasource method to get called is numberOfRowsInTableView. The others do not get called. I rechecked syntax (even tried copying method sig from another project that works), rechecked connections for the outlets (File's Owner to the table, and table delegate and data source to File's Owner, which is the window controller). Still, - (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) tableColumn row: (int) row and -(void) tableView: (NSTableView*) tableView setObjectValue: (id) value forTableColumn: (NSTableColumn*) tableColumn row: (int) index never get called. I also tried [myTable reloadData] when resizing the table (resizing works) but that did nothing. References to the individual columns appear to be valid based on log statements (I cached the column references for convenience), but it's irrelevant because a log at the start of each of the above datasource methods is never printed. As a result, nothing is loaded in the table, and I cannot select individual cells. What would cause this? Incidentally, the correct prototypes for these methods have as their last parameter ... row: (NSInteger) index The difference would only be important if your app was being built as 64-bit. If so, with your prototypes, NSTableView might reject the data source method signatures. Did you check for messages in the run log? (Either check the debugger's run log window in Xcode, or use the Console utility to check the system log.) It's worth emphasizing that in Cocoa frameworks-related code, 'int' or 'unsigned' ought to be a huge red flag to the wary programmer, with a possible transition to all-64-bit-all-the-time looming on the horizon. And that the documentation is still sometimes wrong about the prototypes for delegate method signatures (and often wrong for didEnd... method signatures). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
On Jul 28, 2009, at 2:04 PM, Daniel Child wrote: The only datasource method to get called is numberOfRowsInTableView. What number is it returning? --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
Actually, once I have init'd the window controller and set up the model data, I call showWindow on the controller. Unchecking visible at launch doesn't seem to make any difference. On Jul 28, 2009, at 11:47 AM, Graham Cox wrote: Visible at launch is checked (ON) Which is almost never what you want. Windows should generally be loaded on demand by the app under the direction of their window controller. A window visible at launch won't necessarily even have a controller. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
Thanks for confirming this. On Jul 28, 2009, at 11:43 AM, Graham Cox wrote: Not only are they redundant, this is almost certainly your bug. Objects in a nib are real objects. Therefore you have two of them, both of the same class. Normally File's Owner is the window controller and this is the object you should be referring to in your code. The other object is getting in the way and likely causing problems. You generally use a blue cube for any other object, such as a separate subcontroller that your main controller might want to use, but they definitely won't be the same object - they can't be, as each item in a nib is a distinct, real object. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
I decided the nib was maybe corrupt from my having dragged things from another project onto it. So I started with a fresh xib, got rid of the redundant object (as pointed out by Graham Cox and yourself) and voila: I have references to the tableview and the window. But it's still not working. The only datasource method to get called is numberOfRowsInTableView. The others do not get called. I rechecked syntax (even tried copying method sig from another project that works), rechecked connections for the outlets (File's Owner to the table, and table delegate and data source to File's Owner, which is the window controller). Still, - (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) tableColumn row: (int) row and -(void) tableView: (NSTableView*) tableView setObjectValue: (id) value forTableColumn: (NSTableColumn*) tableColumn row: (int) index never get called. I also tried [myTable reloadData] when resizing the table (resizing works) but that did nothing. References to the individual columns appear to be valid based on log statements (I cached the column references for convenience), but it's irrelevant because a log at the start of each of the above datasource methods is never printed. As a result, nothing is loaded in the table, and I cannot select individual cells. What would cause this? On Jul 28, 2009, at 11:39 AM, Dave Carrigan wrote: On Jul 28, 2009, at 8:31 AM, Daniel Child wrote: Which brings up another question: do I need the "object" (blue cube) at all in the nib if the file's owner is of the same class and presumably represents the same object. Are they redundant? They are completely different things. The blue cube object will cause a brand new object to be instantiated when the nib is loaded. The file's owner is a pseudo-object - it represents an object external to the nib that has already been instantiated before the nib gets loaded. This almost certainly explains why you seem to have two different objects of the same class. -- Dave Carrigan d...@rudedog.org Seattle, WA, USA ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
On 29/07/2009, at 1:39 AM, Daniel Child wrote: Visible at launch is checked (ON) Which is almost never what you want. Windows should generally be loaded on demand by the app under the direction of their window controller. A window visible at launch won't necessarily even have a controller. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
On 29/07/2009, at 1:31 AM, Daniel Child wrote: Which brings up another question: do I need the "object" (blue cube) at all in the nib if the file's owner is of the same class and presumably represents the same object. Are they redundant? Not only are they redundant, this is almost certainly your bug. Objects in a nib are real objects. Therefore you have two of them, both of the same class. Normally File's Owner is the window controller and this is the object you should be referring to in your code. The other object is getting in the way and likely causing problems. You generally use a blue cube for any other object, such as a separate subcontroller that your main controller might want to use, but they definitely won't be the same object - they can't be, as each item in a nib is a distinct, real object. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
That would have been a good guess, but that's not it. Visible at launch is checked (ON). On Jul 28, 2009, at 3:13 AM, cocoa-dev-requ...@lists.apple.com wrote: This came up in another chat I had today. In that case, the window was not set to be visible at launch, so the system deferred actually loading it until it was ready to be shown. Perhaps that's happening to you? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
On Jul 28, 2009, at 8:31 AM, Daniel Child wrote: Which brings up another question: do I need the "object" (blue cube) at all in the nib if the file's owner is of the same class and presumably represents the same object. Are they redundant? They are completely different things. The blue cube object will cause a brand new object to be instantiated when the nib is loaded. The file's owner is a pseudo-object - it represents an object external to the nib that has already been instantiated before the nib gets loaded. This almost certainly explains why you seem to have two different objects of the same class. -- Dave Carrigan d...@rudedog.org Seattle, WA, USA PGP.sig Description: This is a digitally signed message part ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
Sorry, I misled you. There is a controller object and File's owner. File's owner's class is set to the window controller subclass. The window outlets for both of the win controller and file's owner point to the window itself. Which brings up another question: do I need the "object" (blue cube) at all in the nib if the file's owner is of the same class and presumably represents the same object. Are they redundant? On Jul 27, 2009, at 10:57 PM, Graham Cox wrote: On 28/07/2009, at 12:39 PM, Daniel Child wrote: I have a master controller loading a window controller subclass, but for some reason, I cannot get a pointer to the window loaded in the XIB file. I've looked at every connection, and I've also tested the order by of method calls. In the window controller's init: [self window] yields nothing. Likewise in awakeFromNib and windowDidLoad. It's totally mysterious because I have practically identical setups in two other programs, the only difference being that they used nib files and this is xib. But from what I understand, that shouldn't matter. For what it's worth, in the XIB file, the window outlet goes to File's Owner (the window controller subclass). The window contains a table, and (unsurprisingly) [myTable window] also yields nothing. If this is literally true, isn't this the problem? The window outlet of the controller should go to... ta-d!... the WINDOW. That is, the actual window, not its controller, or a view within it, but the NSWindow object. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
On Jul 27, 2009, at 8:39 PM, Daniel Child wrote: I have a master controller loading a window controller subclass, but for some reason, I cannot get a pointer to the window loaded in the XIB file. I've looked at every connection, and I've also tested the order by of method calls. In the window controller's init: [self window] yields nothing. Likewise in awakeFromNib and windowDidLoad. It's totally mysterious because I have practically identical setups in two other programs, the only difference being that they used nib files and this is xib. But from what I understand, that shouldn't matter. For what it's worth, in the XIB file, the window outlet goes to File's Owner (the window controller subclass). The window contains a table, and (unsurprisingly) [myTable window] also yields nothing. Eventually the window does load, but only in its basic nib-drawn form, ignoring all of the initialization that the controller is supposed to do except for two text fields, which do for some reason get initialized. I've spent hours checking connections and stepping through code. Does anyone have a suggestion where I can look to track down this issue. This came up in another chat I had today. In that case, the window was not set to be visible at launch, so the system deferred actually loading it until it was ready to be shown. Perhaps that's happening to you? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow reference remains null after window did load
On 28/07/2009, at 12:39 PM, Daniel Child wrote: I have a master controller loading a window controller subclass, but for some reason, I cannot get a pointer to the window loaded in the XIB file. I've looked at every connection, and I've also tested the order by of method calls. In the window controller's init: [self window] yields nothing. Likewise in awakeFromNib and windowDidLoad. It's totally mysterious because I have practically identical setups in two other programs, the only difference being that they used nib files and this is xib. But from what I understand, that shouldn't matter. For what it's worth, in the XIB file, the window outlet goes to File's Owner (the window controller subclass). The window contains a table, and (unsurprisingly) [myTable window] also yields nothing. If this is literally true, isn't this the problem? The window outlet of the controller should go to... ta-d!... the WINDOW. That is, the actual window, not its controller, or a view within it, but the NSWindow object. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com