On Jul 7, 2009, at 09:35, Brian Hughes wrote:

As I debug I can clearly see that the program is not going through the other path. It is definitely traveling through the path that I am logging. Everything says that returnValue is 22 except the actual tableView. By the way when the program does use the other path everything works fine. So there is something about my code in here:

You're flailing around here. It's time for your to get your thinking cap on. :)

First of all, I assure you that table views and their data sources work fine, in the way that they're documented to work. Almost certainly, if something goes wrong like this, (a) it's not a magical happening, and (b) there's something wrong with your code, somewhere, or with your NIB file. If you can't find anything wrong with your numberOfRowsInTableView: data source method, it's probable that the problem is elsewhere.

Second, you seem uncertain about what your data source is a data source for. Is it a data source for exactly two specific table views, or for those two plus an indeterminate number of others? If exactly two, then the most appropriate pattern (given that you're having problems) would be:

        - (NSInteger) numberOfRowsInTableView: (NSTableView*) aTableView {
                if (aTableView == table1) {
                        ...
                        return numberOfTable1Rows;
                }
                else if (aTableView == table2) {
                        ...
                        return numberOfTable2Rows;
                }
                else {
NSLog (@"Invalid table view"); // bonus points for throwing an exception here
                        return 0;
                }

and set a breakpoint on the NSLog statement to catch the error condition.

Third, everything you've described so far suggests that you actually have more than 2 tables using this data source method, AND/OR the table you're looking at in your window isn't one of these two. So, you need to actually find out. If you are creating table views (or setting their delegates and data sources) via code, you need to scrutinize that code. If you're setting them up in a NIB file, you need to scrutinize the view hierarchy and connections. If you're using bindings to provide any content to your table views, you need to make sure they're correct. If you're using a combination of those techniques, then you're going to have to look carefully for unwanted interactions. You may have to simplify the problem by *removing* some of this infrastructure, then adding it back in a controlled manner.

If the problem you're having isn't in the code you're looking at, look elsewhere. There's more light under the streetlamp, but that may not be where you dropped your nickel.


_______________________________________________

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

Reply via email to