-2

I have been building an app for quite some time, and have added a UIActivityViewController to a UIButton to make it possible to share the app. I followed a youtube tutorial (https://www.youtube.com/watch?v=91mL-eDl6x4) and everything worked out perfectly fine until recently when I just started getting SIGABRT errors from the UIButton.

My short code is:

@IBAction func ShareTapped(sender:UIButton) {
    let aViewController:UIActivityViewController = UIActivityViewController(activityItems: [shareText], applicationActivities: nil)
    self.presentViewController(aViewController, animated: true, completion: nil)
}

And when I tap the button the app crashes and this error message is shown:

"[UIViewController ShareTapped:]:unrecognized selector sent to instance 0x7fc18bc2e260 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [UIViewController ShareTapped:]: unrecognized selector sent to instance 0x7fc18bc2e260"

I have checked so the UIbutton doesn't have any old segues left multiple times, but I can't understand what has happend? Everything worked before.

What should I do?

Please help!

Mate
  • 99
  • 10

1 Answers1

1

The problem is that you changed the name of the function from UIButtonTapped to ShareTapped. But you didn't change the outlet in the storyboard.

matt
  • 515,959
  • 87
  • 875
  • 1,141