Question

Hi guys I know that this argument is been shared already I am getting the App crushing when I attempt to use this code:

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){

    SLComposeViewController *facebook = [SLComposeViewController
                                                  composeViewControllerForServiceType:SLServiceTypeFacebook];



    [facebook setInitialText:@"https://itunes.apple.com"];
    [self presentViewController:facebook animated:YES completion:Nil];

    [facebook setCompletionHandler:^(SLComposeViewControllerResult result) {
        NSString *outPut = nil;

        switch (result) {
            case SLComposeViewControllerResultCancelled:
                outPut =@"Action Cancelled";
                break;
            case SLComposeViewControllerResultDone:
                outPut = @"Posted Successfully";
                break;
            default:
                break;

}

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook" message:outPut delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
        [alert show];



    }];

}

The following is my crash report:

2013-06-25 12:41:24.112 MyApp[11779:1cd03] -[AboutViewController Facebook:]: unrecognized selector sent to instance 0x9c649d0
2013-06-25 12:41:24.114 MyApp[11779:1cd03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AboutViewController Facebook:]: unrecognized selector sent to instance 0x9c649d0'
*** First throw call stack:
(0x1a67012 0x12d3e7e 0x1af24bd 0x1a56bbc 0x1a5694e 0x12e7705 0x21b2c0 0x21b258 0x2dc021 0x2dc57f 0x2db6e8 0x24acef 0x24af02 0x228d4a 0x21a698 0x2ba0df9 0x2ba0ad0 0x19dcbf5 0x19dc962 0x1a0dbb6 0x1a0cf44 0x1a0ce1b 0x2b9f7e3 0x2b9f668 0x217ffc 0x2afd 0x2a25)
libc++abi.dylib: terminate called throwing an exception
(lldb) 

Also provoking the crash it automatically bring me on the main page showing me this line

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
signal SIGBART

I wish to say as well that I am new in programming and probably as you will all notice the error for all of you is simple identify. Will be very grateful if some of you will share your knowledge with me and helping me to found the solution of the crash.

Thanks in advance!

Was it helpful?

Solution

It seems your AboutViewController does not have Facebook: method defined in your .h file. Look carefully its Facebook: with colon. It means your method should have a parameter.

Hope this helps.

Tip: 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.

Learn more about private methods here. Best way to define private methods for a class in Objective-C

BTW, Welcome to stackoverflow :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top