Domanda

I have an NSTableview in class "spielplan", which I can reload easily with reloadData, but how can I reload the Table from my AppDelegate.m???

I think, there is a simple solution, but I don't get it!

È stato utile?

Soluzione

Short answer: You shouldn't.

You class spielplan (which should be renamed to PMGameBoard) is probably a controller class that manages views, including the tableView. So it's the responsibility of this controller to reload the tableView's data should need be.

The external event from your app delegate, whatever it is, should be made available to the spielplan instance by some means of notification. The exact method of communication depends on the type of event (NSNotification, ...). See this objc.io article.

Altri suggerimenti

Create property or outlet (depends on do you use storyboard or not) in your spielplan.h file, for example

@property (nonatomic, strong) IBOutlets UITableView *myTableView;

and in the AppDelegate file get reference to spielplan object and call reload method:

[spielplan.myTableView reloadData];

If spielplan is subclass of UITableViewController you don't have to create outlet or property to the table view in your AppDelegate call:

[spielplan.tableView reloadData];

Bear in mind that when you try to get reference to your view controller from AppDelegate and the view controller is not in view hierarchy it can be deallocated or maybe it hasn't been allocate yet and call reloadData it doesn't make sense.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top