Thread 1: Exception:unrecognized selector sent to instance 0x7fb12cc088c0 exception error
This can happen if you add a selector (a function connected to an event) through the storyboard and then change it in code, resulting in the storyboard being out of sync.
Assuming you're trying to connect buttonAction(sender:UIButton)
with your recordButton
, try doing this:
- Mark your function as @IBAction. (maybe you deleted this by mistake after connecting it to the storyboard?)
@IBAction func buttonAction(sender: UIButton)
- Go to the storyboard and delete the existing connection by going to the connections inspector after selecting the button and then deleting any connections (in my screenshot, I would click the x next to View Controller / Your Function):
- Reconnect the function to the button by dragging the circle next to the event you want to connect to and and dropping over your view controller, and then selecting your buttonAction function.
If this doesn't work try providing some screenshots of your storyboard connections, I'll try to help out more!
Unrecognized selector sent to instance 0x7fecc7011000 In Swift
The problem is this outlet:
IBOutlet weak var tableView: UITableView!
You have hooked it up in the storyboard to the wrong object. It is hooked to the cell, not the table view. It looks like you must have hooked it up and then changed the class of the thing it is hooked to.
Swift unrecognized selector sent to instance error
Two changes for Swift 3:
The selector should look like:
#selector(ClassName.followButtonClick(_:))
The function should have an underscore:
@IBAction func followButtonClick(_ sender: UIButton!) { ...
Notice that these two should be in the same class, otherwise, make sure you initialize the ClassName
class.
If you want the selector method(followButtonClick(_:)
) to be in the UITableViewCell
class. Remove @IBAction
(I don't think you need it there):
func followButtonClick(_ sender: UIButton!) { ...
Swift 4: Unrecognized selector sent to instance when calling a function inside another class
There's no reference to your LoginFunctions from your ViewController
. And you pass self
as the target to the button but self
doesn't have a handleLogin
method.
You need to hold and instance of LoginFunctions
in your ViewController
class. Then pass that reference as the target instead of self
.
class ViewController: UIViewController {
let functions = LoginFunctions()
lazy var loginRegisterButton: UIButton = {
let button = UIButton(type: .system)
button.backgroundColor = Color.darkBlue
button.setTitle("Register", for: .normal)
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitleColor(UIColor.white, for: .normal)
button.layer.cornerRadius = 5
button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 16)
button.addTarget(functions, action: #selector(LoginFunctions.handleLogin), for: .touchUpInside)
return button
}()
}
unrecognized selector sent to instance 0x7ff0ece07a40 ERROR on xcode
I am quite sure the problem is with my code and not with any connections in the storyboard.
No, the problem is indeed a connection. According to a suggestion in your previous question you renamed Hint
to hintButton
which does not rename the connection automatically.
In the storyboard delete the dead Hint
connection and reconnect it to hintButton
.
Related Topics
Process Array in Parallel Using Gcd
Xcode 8.3 Can't Support Swift 2.3
Reading Currently Playing Track in MACos Using Scriptingbridge Not Working
Mutable Binding in Swiftui Live Preview
How to Remove Optional from String Value Swift
Could Not Find an Overload for '^' That Accepts the Supplied Arguments
Implicitly Lazy Static Members in Swift
Checking If a Double Value Is an Integer - Swift
Firebase Storage Downloadurl()' Is Deprecated: Use 'Storagereference.Downloadurlwithcompletion()
Uicollectionview Compositionallayout Not Calling Uiscrolldelegate
How Set Rootviewcontroller in Scene Delegate iOS 13
Swift 4.2 Imagepickercontroller Issue
Xcode Beta 6 "Type of Expression Is Ambiguous Without More Context" Navigationlink
Can an Enum Contain Another Enum Values in Swift
Beginner Swift Sprite Kit - Node Collision Detection Help (Skphysicscontact)
Find Nearest Smaller Number in Array
Today Extension Failed to Inherit Coremedia Permissions From