175

I created a button and added an action for it, but as soon as it invoked, I got this error:

-[NSCFDictionary numberButtonClick:]: unrecognized selector sent to instance
 0x3d03ac0 2010-03-16 22:23:58.811
 Money[8056:207] *** Terminating app
 due to uncaught exception
 'NSInvalidArgumentException', reason:'*** -[NSCFDictionary numberButtonClick:]:  unrecognized selector sent to instance 0x3d03ac0'

This is my code:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        UIButton *numberButton = [UIButton buttonWithType:UIButtonTypeCustom];        
        numberButton.frame = CGRectMake(10, 435, 46, 38);
        [numberButton setImage:[UIImage imageNamed:@"one.png"] forState:UIControlStateNormal];
        [numberButton addTarget:self action:@selector(numberButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview: numberButton]; 
    }
return self;
}

-(IBAction)numberButtonClick:(id)sender{
    NSLog(@"---");
}
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
HelloWorld
  • 7,156
  • 6
  • 39
  • 36
  • Possible duplicate of [How can I debug 'unrecognized selector sent to instance' error](https://stackoverflow.com/questions/25853947/how-can-i-debug-unrecognized-selector-sent-to-instance-error) – Cœur Jul 08 '19 at 05:48

41 Answers41

196

It looks like you're not memory managing the view controller properly and it is being deallocated at some point - which causes the numberButtonClicked: method to be sent to another object that is now occupying the memory that the view controller was previously occupying...

Make sure you're properly retaining/releasing your view controller.

Jasarien
  • 58,279
  • 31
  • 157
  • 188
  • 112
    That's a very astute diagnosis from a very few lines of code. – Michael Morrison Jul 21 '11 at 03:55
  • 43
    OK, so problem identified... but "Make sure you're properly retaining/releasing your view controller." is a suggestion, not a solution. – Alex Gray Sep 01 '11 at 23:58
  • 14
    @alex gray, What? Proper memory management on the view controller solved the problem... I don't understand how that is not a solution? – Jasarien Sep 02 '11 at 09:15
  • Yeah, it was a solution enough for me, who also just experienced this issue. – Jacob Rohde Sep 21 '11 at 06:34
  • 1
    @alexgray may mean that this is not specific enough or does not have example code to illustrate. Would be a good addition. – Old McStopher Sep 30 '11 at 04:31
  • 29
    correct. although this does seem to be "the fix".. and i may be in the minority, (though i still manage to exist), but the connection between the problem and the solution is not immediately obvious. for example, I am encountering `-[NSWindow end]: unrecognized selector sent to instance 0x100523e80` and although i realize the similarities to the OP, and even possibly the cause of problem from your answer, the implementation of a fix is not immediately obvious – Alex Gray Oct 03 '11 at 22:28
  • 14
    It is immediately obvious. Your NSWindow memory management is not correct somewhere along the line. Go through it's life cycle and correct it. – Jasarien Oct 03 '11 at 23:14
  • Does this reason necessarily require the object at `addr` *not* be an instance of the class that defines the selector? Because I'm experiencing this error, but when I `po` the `addr` I get an instance of the correct class that seemingly should have that selector. – devios1 Mar 08 '13 at 00:30
  • 1
    @chaiguy Yes, unless you're dealing with cluster classes, possibly. You might want to ask a full question for your issue, as it's likely something different. – Jasarien Mar 08 '13 at 09:31
  • Also something to look out for is if you originally had the function private, but then changed it to be used by this. – hdost Feb 20 '15 at 18:12
134

For those getting here via Google like I did, which probably pertains more to Xcode 4.2+/iOS 5+ more, what with ARC. I had the same error "unrecognized selector sent to instance". In my case I had a UIButton's target action set up to pass itself as the sender parameter, but later realised I didn't need it and removed that in code. So, something like:

- (IBAction)buttonPressed:(UIButton *)sender {

Was changed to:

- (IBAction)buttonPressed {

Right clicking the UIButton in question showed that the Touch Up Inside event was associated with the view controllers buttonPressed: method. Removing this and reassigning it to the modified method worked a treat.

LeonardChallis
  • 7,759
  • 6
  • 45
  • 76
  • This was very helpful, although I think its own question and response would make it easier to find. – Curtis Inderwiesche Mar 29 '12 at 05:51
  • @LeonardChallis How are you able to reference the sender in buttonPressed if it's not passed as a parameter? – zakdances May 04 '12 at 13:23
  • @yourfriendzak This is for when you **aren't** sending the `sender`. My point was that if you decide to not sent it but have already set up the method, this is when you might see this problem. – LeonardChallis May 04 '12 at 13:35
  • 9
    Very helpful response. I just ran into this exact problem and your solution was exactly right. Was following the Stanford iOS class on iTunesU when this happened. Thanks again for your answer! – Marshall Alsup Jul 10 '12 at 07:11
  • Very helpful! I just created some views with the storyboard editor (no code yet) and I was getting this error when touching a button. This answer fixed my problem – oli206 Jul 25 '12 at 21:36
  • @MarshallAlsup I'm following the same tutorial but I don't know what to change my code to reading this answer. What do I do to fix it (code maybe)? – 1.21 gigawatts Mar 05 '13 at 20:34
  • @MarshallAlsup I figured it out. I had to right click on the button and remove the events (hit the x next to them), then add a new action to that button and enter the same name as my existing function (without the sender) and then click connect. Then remove the duplicate function. – 1.21 gigawatts Mar 05 '13 at 20:57
  • 1
    @LeonardChallis Thanks. I added a complimentary answer to your answer. – 1.21 gigawatts Mar 05 '13 at 23:52
  • 1
    I was just struggling with a similar issue, removed the sender parameter from the selector function, and then wondered how to get the sender. In my case, I was getting the error because I forgot to put a colon after the selector callback, thus causing a calling sequence mismatch. With the colon, I can keep the sender argument. –  May 20 '13 at 22:34
  • This answer will work if only one button is firing the event. Consider if there are 2 or more button which fires the event then we need to have sender to identify. adding a ":" at the end of selector solved me the issue. – Isham Feb 07 '14 at 10:28
  • @isham What do you mean "end of the selector"? Where are you saying the ":" goes? We just tried the solution above but now our method isn't triggering. I am assuming it is because we have multiple buttons and need your ":" to have the sender identify...? – Praxiteles Jun 14 '15 at 05:29
  • let say you have a selector named onButtonClick(UIButton sender){ //your code} and while declaring selector you should clearly mention that @selector(onButtonClick":").. here inside bracket ":" means sender object is expected at the selector. if you forget ":" inside the bracket method signature does not match. Hope this helps. – Isham Jun 15 '15 at 17:40
  • After right-clicking a UI element I had recently touched, I realized that I had created an outlet, and then renamed the variable in the ViewController, breaking the connection. – Hazen Hills Software Oct 01 '16 at 00:06
81

This was the top Google answer for this issue, but I had a different cause/result - I thought I'd add in my two cents in case others stumble across this problem.

I had a similar issue just this morning. I found that if you right click the UI item giving you the issue, you can see what connections have been created. In my case I had a button wired up to two actions. I deleted the actions from the right-click menu and rewired them up and my problem was fixed.

So make sure you actions are wired up right.

Chris K
  • 11,996
  • 7
  • 37
  • 65
  • This was my problem. I renamed a function and changed my code but didn't change the connection in the xib file. – BFTrick Sep 13 '12 at 01:08
  • 2
    THANK YOU! It turned out that I had three methods which I had deleted still referenced. Bothering me for a week! – erdekhayser May 30 '13 at 20:13
26

OK, I have to chip in here. The OP dynamically created the button. I had a similar issue and the answer (after hours of hunting) is so simple it made me sick.

When using:

action:@selector(xxxButtonClick:)

or (as in my case)

action:NSSelectorFromString([[NSString alloc] initWithFormat:@"%@BtnTui:", name.lowercaseString])

If you place a colon at the end of the string - it will pass the sender. If you do not place the colon at the end of the string it will not, and the receiver will get an error if it expects one. It is easy to miss the colon if you are dynamically creating the event name.

The receiver code options look like this:

- (void)doneBtnTui:(id)sender {
  NSLog(@"Done Button - with sender");
}
 or
- (void)doneBtnTui {
  NSLog(@"Done Button - no sender");
}

As usual, it is always the obvious answer that gets missed.

Craig H.
  • 261
  • 3
  • 3
  • 1
    Thank you SO very much! This was my problem (not putting a colon ':' at the end of the name of the selector). How come it is almost always the most stupid simple things that have us geeks banging our heads against the wall at 3 a.m. in the morning? Really THANK YOU! – TWright Sep 22 '13 at 06:57
24

In my case the function was not expecting an argument but the button was configured to send one causing the error. To fix this I had to rewire the event handler.

Here is my function:

enter image description here

Notice it contains no arguments.

Here is an image of my button configuration (right click on the button to view it):

enter image description here

Notice there are 3 event handlers.

To fix this I had to remove each of the event items since one of them was sending a reference to itself to the enterPressed function. To remove these items I clicked on the little x icon next to the name of each item until there were no items shown.

enter image description here

Next I had to reconnect the button to the event. To do this hold down the Control key and then drag a line from the button to the action. It should say "Connect Action". Note: I had to restart XCode for this to work for some reason; otherwise it only let me insert actions (aka create a new action) above or below the function.

enter image description here

You should now have a single event handler wired to the button event that passes no arguments:

enter image description here

This answer compliments the answer by @Leonard Challis which you should read as well.

1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231
14

This can also happen if you don't set the "Class" of the view in interface builder.

  • Agh thank you! This was causing my app to crash on a segue, just forgot to set the controller's class. – Eichhörnchen Jun 04 '14 at 18:04
  • Why does it need to know the class? I'm trying to use a UITableViewSection as a UIView, and so I'm getting this error. The compiler says that UITableViewSection doesn't exist so I presume its internal to UIKit. – Ian Warburton Dec 14 '16 at 13:51
13

In my case, I was using NSNotificationCenter and was attempting to use a selector that took no arguments, but was adding a colon. Removing the colon fixed the problem.

When using a selector name, don't use a trailing colon if there are no arguments. If there's one argument, use one trailing colon. If there are more than one argument, you must name them along with a trailing colon for each argument.

See Adam Rosenfield's answer here: Selectors in Objective-C?

Cœur
  • 37,241
  • 25
  • 195
  • 267
11

I had this problem with a Swift project where I'm creating the buttons dynamically. Problem code:

var trashBarButtonItem: UIBarButtonItem {
    return UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "newButtonClicked")
}

func newButtonClicked(barButtonItem: UIBarButtonItem) {
    NSLog("A bar button item on the default toolbar was clicked: \(barButtonItem).")
}

The solution was to add a full colon ':' after the action: e.g.

var trashBarButtonItem: UIBarButtonItem {
        return UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "newButtonClicked:")
    }

    func newButtonClicked(barButtonItem: UIBarButtonItem) {
        NSLog("A bar button item on the default toolbar was clicked: \(barButtonItem).")
    }

Full example here: https://developer.apple.com/library/content/samplecode/UICatalog/Listings/Swift_UIKitCatalog_DefaultToolbarViewController_swift.html

Pang
  • 9,564
  • 146
  • 81
  • 122
FredL
  • 1,035
  • 9
  • 23
8

The most obvious cause of this (included for completeness) is improperly casting a pointer and calling a method of the wrong class.

NSArray* array = [[NSArray alloc] init];
[(NSDictionary*)array objectForKey: key]; // array is not a dictionary, hence exception
devios1
  • 36,899
  • 45
  • 162
  • 260
  • This is a good hint - not subclassing a view or data object (eg by failing to add subclass name) is another way this happens – Brad M Dec 02 '13 at 22:08
5

How to debug ‘unrecognized selector send to instance’

In most of the cases Xcode do not take us to the exact line where this issue happen. When app crash you won’t see the line of code that caused this, rather you will be taken to App delegate class, in which the error output may look like:

[UITableViewCellContentView image]: unrecognized selector sent to instance

or

[__NSDictionaryI objectAtIndex:] unrecognized selector sent to instance

or

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TestApp.MyViewController viewDidLoad:]: unrecognized selector sent to instance 0xDABCDD'

How to find line of code causing this:

Go to breakpoint navigator. Click ‘+’ option. click ‘Exception Breakpoint’. An new widget like following will apear.

enter image description here

Add following condition block:

-[NSObject(NSObject) doesNotRecognizeSelector:]

enter image description here

You can also put breakpoint for all exception. Now run your code again. this time, breakpoint will trigger when this exception occurs.

WRITTEN BY: Prafulla Singh

Full explanition: https://prafullkumar77.medium.com/how-to-debug-unrecognized-selector-send-to-instance-402473bc23d

Iker Solozabal
  • 1,232
  • 11
  • 16
4

I also had the same issue.

I deleted my uibutton in my storyboard and recreated it .. now everything works fine.

Yohan Dahmani
  • 1,670
  • 21
  • 33
3

I had a similar problem, but for me the solution was slightly different. In my case, I used a Category to extend an existing class (UIImage for some resizing capabilities - see this howto in case you're interested) and forgot to add the *.m file to the build target. Stupid error, but not always obvious when it happens where to look. I thought it's worth sharing...

Mirko Jahn
  • 1,282
  • 1
  • 9
  • 15
3

Another possible solution: Add '-ObjC' to your linker arguments.

Full explanation is here: Objective-C categories in static library

I think the gist is: if the category is defined in a library you are statically linking with, the linker isn't smart enough to link in category methods. The flag above makes the linker link in all objective C classes and categories, not just ones it thinks it needs to based on analyzing your source. (Please feel free to tune or correct that answer. I'm knew to linked languages, so I'm just parroting here).

Community
  • 1
  • 1
Russ Egan
  • 3,568
  • 1
  • 24
  • 12
3

This happened to my because accidentally erase the " @IBAction func... " inside my UIViewcontroller class code, so in the Storyboard was created the Reference Outlet, but at runtime there was any function to process it.

The solution was to delete the Outlet reference inside the property inspector and then recreate it dragging with command key to the class code.

Hope it helps!

Guillermo
  • 159
  • 1
  • 3
2

I think you should use the void, instead of the IBAction in return type. because you defined a button programmatically.

Fa.Shapouri
  • 988
  • 2
  • 12
  • 30
2

I had the same error and I discovered the following:

When you use the code

[self.refreshControl addTarget:self action:@selector(yourRefreshMethod:) forControlEvents:UIControlEventValueChanged];

You may think it's looking for the selector:

- (void)yourRefreshMethod{
    (your code here)
}

But it's actually looking for the selector:

- (void)yourRefreshMethod:(id)sender{
    (your code here)
}

That selector doesn't exist, so you get the crash.

You can change the selector to receive (id)sender in order to solve the error.

But what if you have other functions that call the refresh function without providing a sender? You need one function that works for both. Easy solution is to add another function:

- (void)yourRefreshMethodWithSender:(id)sender{
    [self yourRefreshMethod];
}

And then modify the refresh pulldown code to call that selector instead:

[self.refreshControl addTarget:self action:@selector(yourRefreshMethodWithSender:) forControlEvents:UIControlEventValueChanged];

I'm also doing the Stanford iOS course on an older Mac that can't be upgraded to the newest version of Mac OSX. So I'm still building for iOS 6.1, and this solved the problem for me.

Joseph Pride
  • 165
  • 11
2

On my case I solved the problem after 2 hours :

The sender (a tabBar item) wasn't having any Referencing Outlet. So it was pointing nowhere.

Juste create a referencing outlet corresponding to your function.

Hope this could help you guys.

André DS
  • 1,823
  • 1
  • 14
  • 24
  • Just to add, in my case I forgot to port an `IBAction` to Swift. So it was complaining that it wanted to call that function, but it could not be found. – DevNebulae Jan 21 '20 at 12:45
1

I'm currently learning iOS development and going through the "Beginning iOS6 Development" book by aPress. I was getting the same error in Chapter 10:Storyboards.

It took me two days to figure it out but found out I accidentally set the TableView cell's tag to 1 when I shouldn't have. For anyone else doing this book and receive a similar error I hope this helps.

I really hope future errors in my code are easier to find! hahaha. The debug error did nothing to push me in the right direction to figuring it out (or at least I'm too new to understand the debugger, lol).

Shannon Cole
  • 362
  • 7
  • 21
1

In my case I was using a UIWebView and I passed a NSString in the second parameter instead of a NSURL. So I suspect that wrong class types passed to a functions can cause this error.

jbaylina
  • 4,408
  • 1
  • 30
  • 39
1

..And now mine

I had the button linked to a method which accessed another button's parameter and that worked great BUT as soon I tried to do something with the button itself, I got a crash. While compiling, no error has been displayed.. Solution?

I failed to link the button to the file's owner. So if anyone here is as stupid as me, try this :)

Kirk Woll
  • 76,112
  • 22
  • 180
  • 195
user2875404
  • 3,048
  • 3
  • 25
  • 47
1

Yet another slightly different solution/case.

I am using Xamarin and MvvmCross and I was trying to bind the UIButton to a ViewModel. I had the UIButton wired up to an Outlet and a TouchUpInside.

When Binding I only use the Outlet:

set.Bind (somethingOutlet).For ("TouchUpInside").To(vm => vm.Something);

All I had to do was remove the action (TouchUpInside) connection in XCode and that solved it.

P.S. I guess this is in its base all related to the previous answers and to @Chris Kaminski in particular, but I hope this helps someone...

Cheers.

YKa
  • 3,998
  • 4
  • 20
  • 31
1

I had the same issue. The problem for me was that one button had two Action methods. What I did was create a first action method for my button and then deleted it in the view controller, but forgot to disconnect the connection in the main storyboard in the connection inspector. So when I added a second action method, there were now two action methods for one button, which caused the error.

Harshil.Chokshi
  • 671
  • 15
  • 26
1

For me, it was a leftover connection created in interfacebuilder bij ctrl-dragging. The name of the broken connection was in the error-log

*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[NameOfYourApp.NameOfYourClass nameOfCorruptConnection:]:
unrecognized selector sent to instance 0x7f97a48bb000'

I had an action linked to a button. Pressing the button crashed the app because the Outlet no longer existed in my code. Searching for the name in the log led me to it in the storyboard. Deleted it, and the crash was gone!

Tom Bevelander
  • 1,686
  • 1
  • 22
  • 31
0

I'm replying to Leonard Challis, since I was also taking the Stanford iOS class C193P, as was user "oli206"

"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:"

The problem was that I had the "Enter" button on the calculator connected twice,and a friend pointed out that doing an inspection of the button in the Storyboard showed that 2 entries were on the "Touch Up Inside" attributes when I right clicked on the "Enter" button. Erasing one of the two "Touch Up Inside" "Sent Events" solved the problem.

This showed that the problem is triggered (for the C193P video class on the Calculator Walkthrough on Assignment 1) as 2 sent events, one of which was causing the exception.

Peter_from_NYC
  • 199
  • 1
  • 2
  • 13
0

It can happen when you do not assign the ViewController to the ViewControllerScene in the InterfaceBuilder. So the ViewController.m is not connected to any scene.

Vincent
  • 4,342
  • 1
  • 38
  • 37
0

Including my share. I got stuck on this for a while, until I realized I've created a project with ARC(Automatic counting reference) disabled. A quick set to YES on that option solved my issue.

caiocpricci2
  • 7,714
  • 10
  • 56
  • 88
0

Another really silly cause of this is having the selector defined in the interface(.h) but not in the implementation(.m) (p.e. typo)

jla
  • 9,684
  • 2
  • 21
  • 18
0

Another reason/solution to add to the list. This one is caused by iOS6.0 (and/or bad programming). In older versions the selector would match if the parameter types matched, but in iOS 6.0 I got crashes in previously working code where the name of the parameter wasn't correct.

I was doing something like

[objectName methodName:@"somestring" lat:latValue lng:lngValue];

but in the definition (both .h and .m) I had

(viod) methodName:(NSString *) latitude:(double)latitude longitude:(double)longitude;

This worked fine on iOS5 but not on 6, even the exact same build deployed to different devices.

I don't get why the compiler coudn't tell me this, anyway - problem soled.

Tim T
  • 361
  • 3
  • 7
0

This also might happen when you want to set a property from a ControllerA to a public property inside a custom ControllerB class and you haven't set the "Custom Class" inside the identity inspector in storyboards yet.

Francisco Gutiérrez
  • 1,355
  • 13
  • 23
0

My problem and solution was different and I thought I should post it here so that future readers can save their head from banging to the wall.

I was allocating different xib to same UIVIewController and even after searching everywhere I couldn't find how to correct it. Then I checked my AppDelegate where I was calling initWithNibName and can see that while copying the code, I changed the xib name, but forgot to change UIViewController class. So if none of the solution works for you, check your initWithNibName method.

0xC0DED00D
  • 19,522
  • 20
  • 117
  • 184
0

Happened to me because of conflicting constraint arguments.

Alex Bedro
  • 96
  • 7
0

Basics: Dynamic Invocation

The objective C is a dynamic language which invokes methods by looking at runtime for methods in classes. For example, if there is Class A including method DoSomething(arg1, arg2). If you try to call the method using correct arguments on an object of Class A everything will work fine. However, if the arguments are not passes properly, for example, you called the method with one argument only then the the run-time will treat this as a method call for a different method. Eventually, run-time will fail to find the method (DoSomething with one argument) and will through this exception "unrecognized selector sent to instance".

Solution

Please check what signature for @selector is expected. Usually it is, as you described in the code

-(IBAction)numberButtonClick:(id)sender{
Community
  • 1
  • 1
hadaytullah
  • 1,164
  • 13
  • 14
0

I got the issue too, and at last I found the solution for my issue.I was builded the controller's UI in storyboard , but the controller's UI did not relate its control to code, I use this code to init vc:

    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Me" bundle:nil];
    [sb instantiateViewControllerWithIdentifier:@"HeaderViewController"];

This code above will cause the issue, and after I changed the init code to this below, I resolved the problem:

HeaderViewController *head_vc = [[HeaderViewController alloc] init];
aircraft
  • 25,146
  • 28
  • 91
  • 166
0

I got this issue trying some old format code in Swift3,

let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.respond))

changing the action:"respond:" to action: #selector(self.respond) fixed the issue for me.

sabithpocker
  • 15,274
  • 1
  • 42
  • 75
0

I had this after switching from Swift 2 to Swift 3. The description below is specific, but you can see the generic case of it covers a lot of possible errors.

I had a method called delete in my subclass of SKNode.

func delete(thing: SomeType) 

There is already a method delete on UIResponder, but my method (unintentionally) overloaded it, so it was working fine. Upgrading to Swift 3 changed it to:

func delete(_ thing: SomeType) 

Still working. But then I decided to Swift3ify it and made the parameter mandatory:

func delete(thing: SomeType)

which would have worked fine if I remembered to update the caller, but I didn't so now the caller is calling the no-parameter-name delete method in UIResponder with the wrong type of arguments.

This can obviously happen with any of the long list of of standard methods on SKNode (and probably UIView) that take Any as an argument and so will pass the compilation phase but then fall-over when called.

rghome
  • 8,529
  • 8
  • 43
  • 62
0

My case was: collectionView inside a View

I was trying to add the gestureRecognizer in a config() method that I have wrote by myself. After some workaround i've found that I have simply to move the code inside the awakeFromNib().

override func awakeFromNib() {

   //other code

   let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(handleLongGesture(gesture:)))
   self.collectionView.addGestureRecognizer(longPressGesture)
}

And it worked well.

I hope that this can help someone.

0

In my case:

My protocol definition

 @protocol MyProtocol

- (void)Method;

@end

and I forgot implements the delegate methods.

hope it could help someone.

liu jeff
  • 21
  • 4
0

OK LISTED UP! I'm VERY new to XCODE, had this problem, and figured it out! So if that sounds like you, here's the answer:

When you control + click and drag the button to your ViewController file (so you can code it), you will be asked to fill out the properties of the button in a popup.

The bottom of the popup (under Type) will say "SENDER".

YOU NEED TO CHANGE IT TO "NONE"

Dharman
  • 30,962
  • 25
  • 85
  • 135
0

In my case, in iOS 13, I only had to implement the whole function and selector calling parts put in to main thread.

0

According to Apple, I needed to update an app that had been running fine for years. My app was originally written in Objective-C (well before Swift) and later (mostly) converted to Swift.

I tried many of the solution in this post. When I clicked on a button, instead of calling the handler

func willPause(_ sender: UIButton)
{
    pauseToggle()
}

I got the "unrecognized selector sent to instance" error.

What finally worked for me was adding "@objc" in front of the function

@objc func willPause(_ sender: UIButton)
djm
  • 69
  • 6
0

My case: I forgot to set Home as Class in Storyboard. So basically in the ViewController with a button that was supposed to perform a segue the class wasn't connected to home.. Screenshot in the link

Karo
  • 1