El código de Segue no funciona en el libro de Apress Principio de iOS 5 Capítulo 10 en guiones gráficos

First, let me say that I'm pretty new to Objective-C and iOS programming in general so forgive me if the answer for this is obvious to you guys.

So I'm now going through the Apress Beginning iOS 5 book and in Chapter 10 about Storyboards, I encounter the following problem when trying to Run one of the examples.

As I understand it, this block of code is supposed to pass the text of a task from a list to a text input field on the next page. Here's the code exactly from the book, but I get this error when trying to Build and Run the code: Property 'tableView' not found on object of type 'BIDTaskListController *'.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    UIViewController *destination = segue.destinationViewController;

    if ([destination respondsToSelector:@selector(setDelegate:)]) { 
        [destination setValue:self forKey:@"delegate"];
    }

    if ([destination respondsToSelector:@selector(setSelection:)]) {
        // prepare selection info
        NSIndexPath *indexPath = [self.tableView indexPathForCell:sender]; // Error on this line
        id object = [self.tasks objectAtIndex:indexPath.row];
        NSDictionary *selection = [NSDictionary dictionaryWithObjectsAndKeys:
                                  indexPath, @"indexPath", 
                                  object, @"object",
                                  nil];
        [destination setValue:selection forKey:@"selection"]; 
    }
}

Also, I'm running Xcode 4.4 by the way. Any help would be much appreciated. Thanks.

Saludos, Tim

preguntado el 26 de agosto de 12 a las 16:08

You are trying to access a property called tableView in the current object that the compiler doesn't think exists. How is tableView definido dentro del BIDTaskListController ¿clase? -

1 Respuestas

You have to put this code inside UITableViewController, propable you're using UIViewController, so you don't have reference to tableview or you can add UITableView to your UIViewController and connect IBOutlet to it.

Respondido 26 ago 12, 22:08

Yes, I made the mistake of making BIDTaskListController a subclass of UIViewController instead of UITableViewController. Thanks! - timshim

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.