@mr_cloud
iOS Developer

Как сделать Segue?

Не получается сделать Segue, проблема в PrepareForSegue.
Помогите исправить пожалуйста

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    
    if ([sender isKindOfClass:[UITableViewCell class]])
    {
        UITableViewCell *cell = (UITableViewCell *)sender;
        NSString *tmpStr = cell.textLabel.text;
        VCViewController *destinationController = (VCViewController *) segue.destinationViewController;
        
        [segue.destinationViewController setMyProperty:tmpStr];
    }
}
  • Вопрос задан
  • 2514 просмотров
Пригласить эксперта
Ответы на вопрос 2
@yakubov
Думаю проблема в том, что надо заменить
[segue.destinationViewController setMyProperty:tmpStr];

на

[destinationController setMyProperty:tmpStr];
Ответ написан
morozovdenis
@morozovdenis
у класса нет такого поля,

1. посмотрите в storyboard что у вас там прописан нужный class и

2. убедитесь что у этого класа есть такое проперти

3. добавьте вот такой лог и скорее всего вы увидите что там не тот класс
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    
    if ([sender isKindOfClass:[UITableViewCell class]])
    {
        UITableViewCell *cell = (UITableViewCell *)sender;
        NSString *tmpStr = cell.textLabel.text;
        VCViewController *destinationController = (VCViewController *) segue.destinationViewController;

        NSLog(@"%@", destinationController.class);

        [segue.destinationViewController setMyProperty:tmpStr];
    }
}
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы