Hi,
I'm trying to use the SCTableViewModel in a dynamic context. I have a navigation controller set up which uses SCTableViewModel. There are some cells which pushes a new viewcontroller to the navigation stack. In this controller there is an add button, which adds a new object to the model and pops the new viewcontroller and goes back to the root. When this change occurs I need add a new cell to show that a new object is added.
Let me give you an example of what I'm trying to do.
The root view controller is "My profile" and I have my information entered in this view. This page also contains my cars in different cells. There is a cell which says "Add a new car". When I add the new car in the new controller, it goes back to "My Profile". If I leave it to that, I can see that I have added the new car. What I need to do is change "My Profile" table and show the new content also. My code basically looks like:
- (void) viewDidLoad {
[super viewDidLoad];
tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
[self constructSection1];
[self constructSection2];
}
- (void) constructSection1;
- (void) constructSection2;
What I tried doing is like:
- (void) viewDidLoad {
[super viewDidLoad];
tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
}
- (void) viewWillAppear {
tableViewModel = nil;
tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
[self constructSection1];
[self constructSection2];
}
- (void) constructSection1;
- (void) constructSection2;
I also tried:
- (void) viewDidLoad {
[super viewDidLoad];
tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
}
- (void) viewWillAppear {
[tableViewModel clear];
[self constructSection1];
[self constructSection2];
}
- (void) constructSection1;
- (void) constructSection2;
I also tried the method removeAllSections instead of clear.
None of these code works as intended. The first solution seems to work, but the autoscroll for the keyboard doesn't work anymore and I think it's not a good programming approach. I don't know what to do and this is one of the most crucial things in my project. I hope you can help.
Thanks,
Oguz