Hi, everyone.
I am working on an iPhone application but something strange happen. I think I can ask you for advice.
I implemented a TableView and a custom view as a create new object form. I make the custom view slide up when user tab 'Add' button in the tool bar in TableView like the code below:
- (void)slide_up_form:(id)sender {
CustomViewController *controller = [[CustomViewController alloc] init];
// Assign this controller to use add_entity: message to TableView.
controller.parent = self;
[self presentModalViewController:controller animated:TRUE];
}
// To update TableView presentation.
-(void)add_block:(Block *)newBlock
{
[blockArray insertObject:newBlock atIndex:0];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tblCameraList insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationNone];
[self.tblCameraList scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]
atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
and in custom view, user fill the form and tab 'Save' button. So I did save the entity to Core data. and need to update the TableView with new object, so I code following statement in custom view:
@synthesize parent;
- (void)save_block:(id)sender {
// save entity.
[self.parent add_block:newBlock];
// Slide down the custom view and show the TableView.
[[self parentViewController] dismissModalViewControllerAnimated:TRUE];
}
I have tested this already in simulator and iPhone. when user tab 'Save' button, the application saved the new entity, but it doesn't update TableView with new entry.
Could you give your advice to solve this problem?