Building iOS application that connects to contacts application and manipulate them.
What I have
Tableview
class that manages the cells, implements method that retrieve all the contact list from Addressbook, and display the array of contents in the table view cells. Imports Person
.
DetailedView
, when tapping on a cell it takes you to that detailed view where you can change the values of the data, name, phone, etc.
Class Person
has properties that tableview imports to receive the address book contacts details, name, last name, etc.
What I want
When the user adds new contacts from the contact app (Apple's one), when bring the app to foreground again and make it active, the tableviewlist updates the view and lists all the contacts including the latest one added. Where is the best place to make sure that I always have updated my array & reloaded my tableview?
Reload your tableview inside viewWillAppear method. Then place one more check in "applicationWillEnterForeground" method of your appdelegate file. Check the controller and tableview objects has there current instance. If so reload your table here too.
Let your controller is MyCont And make sure you have created property of your tableview object in controller class ok. Now Go to appdelegate.h and write
@property(nonatomic,retain) MyCont *cont;
Goto appdelegate.m and use
@synthesize cont;
Now goto viewDidLoad() method of MyCont class and write
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appdelegate.cont = self;
Now goto applicationWillEnterForeground() of AppDelegate class and write
if(cont)
{
[cont.tableviewobject reloadData];
}
By doing all this your tableview datasource metods will be fired.