user3610962
user3610962

Reputation: 21

Crash on segue to new view controller

I am having trouble adding a new view controller to my project. In the story board, i added a new view controller. Then i added the new view controller files. I added a segue from my detailed disclosure table view to this new view controller however when i run it and try to click the detailed button, it crashes and gives me this error.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailsViewController setCompletionHandler:]: unrecognized selector sent to instance 0xa235050'

Does anyone know how to resolve this?

Thanks so much!

EDIT:

UIDetailsViewController.h

#import <UIKit/UIKit.h>

@interface UIDetailsViewController : UIViewController

@end

UIDetailsViewController.m

#import "UIDetailsViewController.h"

@interface UIDetailsViewController ()

@end

@implementation UIDetailsViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

Upvotes: 1

Views: 237

Answers (2)

Omarj
Omarj

Reputation: 1159

Whenever you have unrecognized selector crash in your apps. It means your methods are not defined in your class or not available. Remember, private methods are not accessible via class objects.

Edit:

Rp: to your answer,using prepareForSegue it will be something like that so event if you don't have it this will not make any problem for you ?

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"EventDeatailSeg"]) {

        EventDetailViewController *editVc = segue.destinationViewController;
        editVc.myEvent = currentEvent;
    }

}

Upvotes: 2

user3610962
user3610962

Reputation: 21

I figured out what I was doing wrong. I didn't have the prepareForSegue for the segue to the new view controller. Thanks for all the help guys!

Upvotes: 0

Related Questions