-3

I have a iOS app with a view which contains a container holding a tableView. I want to access a function from this tableView controller, but I don't want to create a new instance of this tableView in the process. I tried this and it creates a new instance meaning that I can't change variables that are displayed on the view.

From my FirstViewController, how can I access the function updateBuckets in my BucketTableViewController which is already running an instance?

Currently I'm trying self.BucketTableViewController.updateBuckets(self.bigArray) and receiving the error FirstViewController does not have a member named BucketTableViewController

Marcus
  • 9,032
  • 11
  • 45
  • 84
  • 1
    Some example code would be really helpful, but just from reading through this it sounds like you should implement the [delegate pattern](https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/Delegation.html). – justinpawela Jul 07 '15 at 18:25

1 Answers1

-1

See this recent answer: how can i update other controllers' UI in swift?

Notifications are probably your best bet. Create a notification in your FirstViewController called "dataUpdated" or something. In your BucketTableViewController, you can watch for that notification.

Alternatively, if the "UI" you're updating is just your table itself, you should just update the data source, then call reloadData() on your tableview.

Community
  • 1
  • 1
Chris Slowik
  • 2,859
  • 1
  • 14
  • 27