Reputation: 11175
I have just opened up the newest Xcode beta (8.3 beta 2) and am in the process of converting my code to Swift 1.2. I have ran into an issue with a particular line of code that I can't figure out the solution to.
Basically I am getting the error: Objective-C method 'textFieldShouldReturn:' provided by method 'textFieldShouldReturn' conflicts with optional requirement method 'textFieldShouldReturn' in protocol 'UITextFieldDelegate'
That is on this code:
@IBAction func textFieldShouldReturn(textField: UITextField!)
{
budgetNameText.resignFirstResponder()
}
Anyone know the solution?
Upvotes: 0
Views: 320
Reputation: 22343
As you see in your error-message, there is already a method called like your method. So your problem is, that in the UITextFieldDelegate
, there is also a method called textFieldShouldReturn
. So you need to rename your IBAction
method to something else.
This is the method the delegate provides:
func textFieldShouldReturn(textField: UITextField) -> Bool {
return true
}
Upvotes: 1