Reputation: 6475
I have a problem with prepareForSegue
method. I need to pass NSString
from one view to another but all I get is:
2013-08-13 12:13:45.765 DailyPhotos[12551:907] -[ArchiveViewController textLabel]: unrecognized selector sent to instance 0x1e5592f0
2013-08-13 12:13:45.775 DailyPhotos[12551:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ArchiveViewController textLabel]: unrecognized selector sent to instance 0x1e5592f0'
*** First throw call stack:
(0x328852a3 0x3a52a97f 0x32888e07 0x32887531 0x327def68 0x813dd 0x34a1ade9 0x8174d 0x3474f28d 0x347d1f81 0x33193277 0x3285a5df 0x3285a291 0x32858f01 0x327cbebd 0x327cbd49 0x3638f2eb 0x346e1301 0x78fb9 0x3a961b20)
libc++abi.dylib: terminate called throwing an exception
Here is my prepareForSegue
implementation:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Checking the segue to perform
if ([[segue identifier] isEqualToString:@"projectDetailsSegue"]) {
AlbumViewController *destinationView = [segue destinationViewController];
// Creating variable with selected cell
UITableViewCell *selectedCell = (UITableViewCell *)sender;
// Passing the cell title to destination cell
destinationView.projectTitle = @"tmp";
NSLog(@"%@", selectedCell.textLabel.text);
}
}
For now I'm passing @"tmp"
and it works but when I try to pass anything connected with selectedCell
it crashes. Why is this happening? How can I reapir this problem?
Upvotes: 0
Views: 112
Reputation: 2207
You are using the sender to get your selectedCell.
But as you can see in the error, your sender is not an UITableViewCell, but an ArchiveViewController. Probably because you are doing a:
[self performSegueWithIdentifier:@"projectDetailsSegue" sender:self];
What you should be doing is:
[self performSegueWithIdentifier:@"projectDetailsSegue" sender:*yourCell*]
;
Upvotes: 1