I am trying to update a UILabel in a parent View after someone makes a change in a modal view. So, after they click "save" ... the newly entered value would change what text is displayed on the parent view controller.
But, I can't seem to get that UILabel to refresh the newly entered value.
Any ideas on what I can try? I've tried a few things, but being the view is already loaded, nothing is getting "refreshed".
Thanks!
To elaborate on my comment. This is how I would implement a delegation method to update the label.
In the header of the parent view controller:
And in the implementation:
Here you see the delegation method in the top.
The header of the modal view controller would contain the delegation protocol like this:
The implementation of the modal view controller would contain a method similar to this one:
When the save button is pressed, the delegate is notified and the text in your text view is sent through the delegation method.
in SWIFT:
ParentViewController :
In OtherView:
There are many ways to do this. One way is to use
NSNotificationCenter
to be able to do calls between different classes. So in the parent view you will have a function responsible for the update (lets call it updateLabel) and you will do the following:Now in other view simply post a notification in the save button:
EDIT: I have to mention 2 things here:
NSNotificationCenter
that you used in the main view by adding[[NSNotificationCenter defaultCenter] removeObserver:self];