Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
The following method has no warnings or errors associated with it in Xcode.

Code:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    ChecklistsViewController *clvc = [segue destinationViewController];
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    clvc.htmlString = [array2 objectAtIndex:indexPath.row];
}

I receive the following message at runTime.

Code:
"'NSInvalidArgumentException', reason: '-[ChecklistsViewController setHtmlString:]: unrecognised"

I am developing for iPad so these controllers have been 'targeted for iPad' if that makes any difference.

Why is setHtmlString unrecognised? It is set as a public NSString property in the destinationViewController.

The destinationViewController is not embedded in a navigation controller.
 
Last edited by a moderator:
First, you didn't provide the entire error message. I suspect that it says that it's an unrecognized selector on the object that is actually pointed at by the segue (segue.destinationViewController) - maybe a UIViewController or UITableViewController object. Stop in the debugger and determine exactly what the object is that gets stored in your clvc variable.

If that is the case, it means that the view controller that the segue points at is not a ChecklistsViewController. Double check that and get back to us.
 
Full error message

2012-05-12 09:05:19.881 readHTML[379:f803] -[ChecklistsViewController setHtmlString:]: unrecognized selector sent to instance 0x6d7e780
2012-05-12 09:05:19.893 readHTML[379:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ChecklistsViewController setHtmlString:]: unrecognized selector sent to instance 0x6d7e780'
*** First throw call stack:
(0x13c9022 0x155acd6 0x13cacbd 0x132fed0 0x132fcb2 0x2c04 0x43e4be 0xa4581 0xa47fa 0x93985d 0x139d936 0x139d3d7 0x1300790 0x12ffd84 0x12ffc9b 0x12b27d8 0x12b288a 0x13626 0x247d 0x23e5)
terminate called throwing an exception(lldb)

----------

array2 contains strings only. the htmlString variable is a string property.

there are no warnings or errors in Xcode at compile time (before run time).
 
Obviously, you're trying to call the method on ChecklistsViewController called setHtmlString.
Tada, rocket science debugging.
Obviously somewhere, on a button or whatever you have that code (i didn't read through all the code), so therefore your code is failing hard.
 
Not trying to hijack the post but in all my segues I use segue.destinationViewController instead of [segue destinationViewController]

Is there a big problem with this?
 
That's what I thought. Thanks
Brackets-syntax is called Objective C 1.1, using the DOT syntax is actually Objective C 2.0.
Allthough I've had some issues with mixing them which caused alot of confusion, i believe the dot syntax is mostly used for lets say setting properties etc.
Square brackets are ofcourse needed to call Methods on classes/objects.
 
Brackets-syntax is called Objective C 1.1, using the DOT syntax is actually Objective C 2.0.
Allthough I've had some issues with mixing them which caused alot of confusion, i believe the dot syntax is mostly used for lets say setting properties etc.
Square brackets are ofcourse needed to call Methods on classes/objects.

Right, which is why I use segue.destinationViewController. To me that reminds me that the destinationVC is a property of the segue (maybe, I am kinda new to this stuff) whereas when I call [self performSegue...] it is a method on the self object
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.