iOS TabBarController

-1

Hello, I am having a problem with the implementation of the save function in a TabBarController, for which, I have followed the advice of someone from the community and to whom I thank you very much, but I have a problem and I do not get that works.

As always, I leave the repository of GitHub so that anyone can download the project and I can get a cable.

The problem is that from each of the views of the TabBarController, I need to be able to make changes to the specific food, that is, if I am in the view of the name of the food and make any changes and I give to save, that I will keep the new name, which, when I return to the list of meals, will appear updated, the same thing I need with the image and the evaluation.

I've been thinking about it for a while now, but I can not get it to work, I'd appreciate it if you could give me a hand, since they've asked me and not even the teacher can help me ...: S

Greetings and many thanks in advance.

    
asked by Alfred 03.05.2018 в 18:13
source

1 answer

1

I think I could understand you, what you need is for your ViewController (tabBar 1), to be updated when your ViewController (tabBar 3) modifies an entity or model. There are several methods or ways that could help you but the easiest option is Notifications. Notifications can be sent between viewControllers, some send and others hear the events and react to them, then I'll show you an example.

ViewController (tabBar 1)

func viewDidLoad () {  super.viewDidLoad ()  NotificationCenter.default.addObserver (self, selector: #selector (observer (notification :)), name: Notification.Name.dataChange, object: nil) }

func observer (notification: NSNotification) {  // Here you will do a reloadData or updateUI to update the information. }

ViewController (tabBar 3)

func downloadData () {

// After downloading information or modifying it

NotificationCenter.default.post (name: .dataChange, object: nil) }

// Utilities extension Notification.Name {     static let dataChange = Notification.Name ("dataChange") }

    
answered by 09.05.2018 / 00:57
source