V
V
Vanya Ivanov2014-06-26 09:36:05
Objective-C
Vanya Ivanov, 2014-06-26 09:36:05

How to make segue?

It is not possible to make Segue, the problem is in PrepareForSegue.
Help fix please

- (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];
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yakubov, 2014-06-26
@yakubov

I think the problem is that you need to replace
[segue.destinationViewController setMyProperty:tmpStr];
on
[destinationController setMyProperty:tmpStr];

D
Denis Morozov, 2014-06-26
@morozovdenis

the class does not have such a field,
1. look in the storyboard that you have the required class written there and
2. make sure that this class has such a property
3. add this log and most likely you will see that the wrong class is there

- (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];
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question