iphone - Updating a cell in UITableViewController after changes in a DetailViewController -


i have simple setup: rootviewcontroller (which uitableviewcontroller). each cell in shows stats different person. can tap on of these cells push on detailviewcontroller (uiviewcontroller), , modify stats (which stored in model object). after user done modifying stats person, click button, causing popviewcontrolleranimated called.

my question is: what's best way know in rootviewcontroller stats player have been changed, , updated cell accordingly? have record in rootviewcontroller cell tapped, , call appropriate setneedsdisplay after detailviewcontroller completes? , if so, method should from? viewwillappear?

or there nicer way? seems it'd common task, , i'm missing obvious.

this depends on how model designed , whether or not you're using core data.

the basic principle observe properties of model objects might change in detail views. when changes in detail controller, somehow mark table cell dirty. then, when table view becomes visible again, changed cell [tableview cellforrowatindexpath:] , reconfigure cell. cellforrowatindexpath: method handily return nil if cell not visible keep spending time updating cells don't need it.

if you're using core data (and should be), nsfetchedresultscontroller of work you. observe model objects , send controller:didchangeobject:atindexpath:forchangetype:newindexpath: message delegate each changed cell. then, can make proper changes table view.

i recommend creating new xcode project using navigation-based application template use core data storage checkbox ticked. template has default implementation of aforementioned pattern.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -