user4039232
user4039232

Reputation:

Implementing TableView Navigation xcode 6

Good afternoon,

I'm trying to follow the tutorial from this website: http://www.techotopia.com/index.php/Implementing_TableView_Navigation_using_Xcode_Storyboards to implement a TableView Navigation, but in the last step I get an error from my xcode.

I'm going to post the code where I have the error code because I'm a little desperated about that error. I hope you can help me.

CarDetailViewController.m - TableViewStory

    #import "CarTableViewController.h"
    #import "CarTableViewCell.h"
    #import "CarDetailViewController.h"

    @implementation CarDetailViewController
    @synthesize makeLabel = _makeLabel;
    @synthesize modelLabel = _modelLabel;
    @synthesize imageView = _imageView;
    @synthesize carDetailModel = _carDetailModel;

    - (void)viewDidLoad
    {
        [super viewDidLoad];

        self.makeLabel.text = [self.carDetailModel objectAtIndex:0];
        self.modelLabel.text = [self.carDetailModel objectAtIndex:1];
        self.imageView.image = [UIImage imageNamed:
                                [self.carDetailModel objectAtIndex:2]];
    }

    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if ([[segue identifier] isEqualToString:@"ShowCarDetails"])
        {
            CarDetailViewController *detailViewController =
            [segue destinationViewController];

            NSIndexPath *myIndexPath = [self.tableView
                                        indexPathForSelectedRow];
------------PROPERTY TABLEVIEW NOT FOUND ON OBJECT OF TYPE 'CARDETAILVIEWCONTROLLER'
            detailViewController.carDetailModel = [[NSArray alloc]
                                                   initWithObjects: [self.carMakes
                                                                     objectAtIndex:[myIndexPath row]],
------------PROPERTY CARMAKES NOT FOUND ON OBJECT OF TYPE 'CARDETAILVIEWCONTROLLER'
                                                   [self.carModels objectAtIndex:[myIndexPath row]],
                                                   [self.carImages objectAtIndex:[myIndexPath row]],
                                                   nil];
        }
    }

    @end

CarDetailViewController.h

#import <UIKit/UIKit.h>


@interface CarDetailViewController : UIViewController

@property (strong, nonatomic) NSArray *carDetailModel;
@property (strong, nonatomic) IBOutlet UILabel *makeLabel;
@property (strong, nonatomic) IBOutlet UILabel *modelLabel;
@property (strong, nonatomic) IBOutlet UIImageView *imageView;

@end

Thanks in advance.

Upvotes: 0

Views: 71

Answers (2)

Wayne
Wayne

Reputation: 60414

The prepareForSegue you've pasted into CarDetailViewController comes from CarTableViewController in the tutorial. Presumably, that class extends UITableViewController (by virtue of which it has a tableView property) and has a custom carMakes property.

But that just relates to this one specific case. I think it's more important to understand what the error you got means, so that you can recognize how to fix it in the future. Your code was referencing properties that could not be found, because they do not exist. That's why you saw an error telling you that properties could not be found. It's actually a pretty straightforward error message.

Upvotes: 0

Andy Obusek
Andy Obusek

Reputation: 12832

prepareForSegue needs to go in CarTableViewController NOT CarDetailViewController

Looks like there was a part 1 of the tutorial, make sure you followed it as well: http://www.techotopia.com/index.php/Using_Xcode_Storyboards_to_Build_Dynamic_TableViews_with_Prototype_Table_View_Cells

Upvotes: 1

Related Questions