I have a tableview based app with sqlite database and am having difficulty getting the original root view controller to refresh the table after I add a record from a different view controller. I tried adding the object to the array used from rvc and even tried reloading the entire database like I do at the opening of the app. None of these result in the new record showing after clicking save. New record only shows when app is closed and started up again. I am not sure what I'm doing wrong.
- (void) save_Clicked:(id)sender {
ConditionsAppDelegate *appDelegate = (ConditionsAppDelegate *)[[UIApplication sharedApplication] delegate];
//Create a Condition Object.
Condition *c = [[Condition alloc] init];
NSInteger newId = c.getNextConditionId;
Condition *cond = [[Condition alloc] initWithPrimaryKey:newId];
cond.condition_area = txtConditionArea.text;
cond.condition_detail = txtConditionDetail.text;
cond.condition_name = conditionName;
//Add the object
[appDelegate addCondition:cond];
[cond addCondition];
[appDelegate populateFromDatabase];
rvc.conditions = [appDelegate activeConditions];
// UPDATE THE TABLEVIEW
[rvc.tableView reloadData];
// release
[cond release];
[c release];
//Dismiss the controller.
[self.navigationController dismissViewControllerAnimated:YES completion: nil];
}
Aucun commentaire:
Enregistrer un commentaire