1
votes

I'm getting this error:

[Clima.WeatherViewController searchPressed:]: unrecognized selector sent to instance 0x7f996b204020 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Clima.WeatherViewController searchPressed:]: unrecognized selector sent to instance 0x7f996b204020'

Here is my code:

IBOutlet weak var searchField: UITextField! 
IBAction func searchedButtonPressed(_ sender: UIButton) { 
         searchField.endEditing(true);
         print(searchField.text!) 
}
1
IBOutlet weak var searchField: UITextField! IBAction func searchedButtonPressed(_ sender: UIButton) { searchField.endEditing(true); print(searchField.text!) }Dhanraj Rathinam
Welcome to Stack Overflow. Please take the tour and review How to Ask. It looks pretty obvious from the error message. Your code is calling searchPressed on a view controller that does not have a searchPressed function.DonMag
Select your button and look at the Connections Inspector pane. I'm guessing your button has a connection to searchPressed but your renamed the function in your code to searchedButtonPressedDonMag

1 Answers

0
votes

You just have to disconnect you IBAction of your button & reconnect it. Because it seems that you had changed your IBAction function name after connect it. So your story board still has connection with old name search Pressed. & You already renamed it into searchedButtonPressed so your story board can not find this new name.

For disconnect your IBAction method:

right click on search button in story board & you will see connections you made in manu, close the connection with little colse button placed on top of the corner with the name searchPressed.

For reconnect your IBAction method:

Ctrl press on the keyboard & dreg on the search button to the small circle you will see beside your IBAction method.