Hello fellow programmers. This error has been bugging me for a couple of hours and I just do not seem to get it.
Error shows as follow property 'text' not found on object of type "UITableview".
I tried to do a segue from one screen containing two table views, showing the selected values from the two table views in to two table cell's on the next page. Thats when it went all wrong.
The code:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"sendStationSegue"]) {
StationSelectedViewController *tosecondview =[segue destinationViewController];
tosecondview.locationCell = _newsTable;
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
_locationCell.text = _dataSend; //shows the error here
}
Second view header containing these of course:
@property (strong, nonatomic) IBOutlet UITableView *locationCell;
@property (strong, nonatomic) IBOutlet UITableView *destinationCell;
Everything is connected and synthesized.
Please help me out. Please don't drill me into the ground, since I am new to iOS developing.
Thanks in advance
You are trying to set the 'text' property on a UITableView which does not have that property. Looking at your code, you are trying to pass an entire UITableViewCell to another view.
Perhaps it's a better solution to extract the NSIndexPath using:
NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow];
And then the selected cell:
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexpath];
And finally the value:
NSString *selectedValue = selectedCell.textLabel.text;
You can then pass this value to the other view by creating a NSString in it's header file and setting its value something like.
tosecondview.selectedLocation = selectedValue;