0

I'm not sure if I explained this correctly in my question, so I'll explain it here. Please excuse my iOS illiteracy, complete newbie here.

The master view controller is a UITableViewController that holds a list of items. So, each cell contains an item. This list is populated from a Core Data model.

If I want to add an item, there's an Add button that takes me to a different view controller that has a text field. I write the item name in the text field, press the Done button and it adds it to Core Data, and unwinds back to the UITableViewController.

I want the table view to reload its data as soon as the unwind happens, so the user sees that his item has been entered into the list. I have to use a refresh control in order for the table to reload its data.

Is there a method whose code runs once the part written in bold happens?

Thanks in advance.

Fares K. A.
  • 1,273
  • 5
  • 24
  • 47

1 Answers1

0

You can reload your table view data in the viewWillAppear method of the UITableViewController, which is called every time your view appears on screen. You can see this question for more details on the view controller lifecycle.

Community
  • 1
  • 1
p4sh4
  • 3,292
  • 1
  • 20
  • 33
  • `reloadData` is a poor way to update a table as it gives the user no idea of what has changed. Use `insertRowsAtIndexPaths` which gives the user visual feedback with animation. – Droppy Aug 06 '14 at 14:11