Уважаемые гуру, подскажите как обновить таблицу после изменения массива данных из другого контроллера.
//STNViewController.h
@interface STNViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) IBOutlet UITableView *mytableView;
- (void)reloadData;
@end
// STNProfileViewController.m
- (void)reloadData{
[[self mytableView] reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[STNSingleton singleton].profilesNames count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* const cellAdd = @"Cell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier: cellAdd];
cell.textLabel.text = [[STNSingleton singleton].profilesNames objectAtIndex:indexPath.row];
return cell;
}
//Класс, где обновляются данные STNProfileViewController.m
- (IBAction)saveButtonPressed:(id)sender {
STNProfile *profile = [[STNProfile alloc]init];
[profile setProfileWithExercises:[exersisesField.text intValue] andName:[profileName text]];
[[[STNSingleton singleton] profilesNames] addObject: profile.nameP]; //данные обновились.
UIStoryboard *myStoryboard = [self storyboard];
STNViewController *stnvc = [myStoryboard instantiateViewControllerWithIdentifier:@"STNViewController"];
[stnvc reloadData]; //метод вызывается, но таблица не перезагружается...