carlkassar
carlkassar

Reputation: 7

segue not working causing app to crash

my code is breaking on the segue. the segue was modal at first , i tried to change it to push but its still not working my code is the following :

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if ([[segue identifier ] isEqualToString:@"detailLoanSeg"]){
    detailLoan *theController=[segue destinationViewController];
    theController.time=_time;
    theController.cuurLoan=_cuurLoan;
    theController.currName=_currName;
   }
}

and the error in xcode is :

 014-05-07 04:38:11.257 LoanCalc[1561:a0b] -[UIViewController setTime:]: 
 unrecognized selector sent to instance 0xa05f1f0  
 2014-05-07 04:38:11.266 LoanCalc[1561:a0b] *** Terminating app due to uncaught 
 exception 'NSInvalidArgumentException', reason: '-[UIViewController setTime:]: 
 unrecognized selector    sent to instance 0xa05f1f0'

Upvotes: 0

Views: 413

Answers (2)

danh
danh

Reputation: 62686

It looks like, in storyboard, you forgot to indicate the custom class of the destination view controller. In storyboard, select that destination VC, click the third inspector from the right and set it's Custom Class to "detailLoan" (which violates class naming convention).

The error is that your destination vc is a generic UIViewController, which naturally doesn't implement the setTime: method.

Upvotes: 4

smyrgl
smyrgl

Reputation: 854

Are you sure the destination class is your View Controller and not a UINavigationController? Put a breakpoint and check what theController class is. Also make sure that the view controller in the Storyboard has its class set from the default UIViewController to your custom subclass. It's almost certainly one of those two issues.

Upvotes: -1

Related Questions