On May 5, 2011, at 16:21, Martin Batholdy wrote:

> I have a singleton class that manages a tableView (and provides the 
> datasource).
> 
> Now I would like to update this tableView from another class.
> 
> Since the class that manages the tableView is a singleton I don't have to 
> initiate a new instance of that class.
> So I thought there should be no problem to change the content of the 
> datasource for the tableView and then update the tableView with [table 
> reloadData]; from a different class.
> 
> I indeed can change the datasource (a mutable Array) but the reloadData 
> command doesn't update the content of the table in the window.

I don't think you mean this. The data source is an object that conforms to the 
NSTableViewDataSource protocol. It isn't the underlying array that the object 
"managing" the table view refers to.

I think you're trying to say you want to switch the underlying array, not the 
data source, but perhaps you mean the data source, I don't know.

> What am I doing wrong?
> Why has the [table reloadData]; command in the updateView-method no effect on 
> the table when it is evoked from a different class (see updateTest.h)?
> 
> I tried to isolate the code from my main project;
> 
> This test-project contains three classes:
> The one that is connected to the preferences.xib providing the datasource for 
> the tableView – tableViewController.h
> the tableview_testAppDelegate.h
> and a class that tries to change the data datasource and tries to send a 
> request to update the tableView – updateTest.h
> 
> I have a preference.xib file with a tableView that is connected to the 
> preference-object (provides the datasource).

You're currently fighting on too many fronts. You're running from problem to 
problem, hoping that something you try for one will solve another.

I very much suspect that you have multiple objects somewhere that you intend 
there only to be one. You could, for example, have two table views, one on top 
of the other. Or you have two underlying arrays, or two array controllers, or 
two objects of the singleton class.

You'll get up to speed faster if you pick a problem and stick with it till it's 
solved. I'd start with "I changed the underlying array and the table view 
doesn't change visually". Keep in mind that frameworks support for table views 
*isn't* buggy. It's a fundamental, mainstream capability, used by thousands of 
developers. If you start by thinking it might be doing "the wrong thing", 
you're only wasting your own time. (Bugs in the frameworks are always possible, 
of course, but I'd bet money you aren't finding any.)

I hope this doesn't sound discouraging. You just need to approach things 
systematically, so that you can conceptualize in Cocoa terms as you go.


_______________________________________________

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