chirag shah chirag shah - 27 days ago 11x
iOS Question

in swift 3 on button click application is crash

I have developed one project in Swift 2.2 and after Swift 3 launch I need to convert it in Swift 3 and make compilable with iOS 10. But after converting the project i face some issue like when I clicked on button which connected with storyboard my application is crash with give reason unrecognized selector sent to instance . It is working in swift 2.2 and i have not change any thing.

@IBAction func btnTwitter_Clicked(sender:UIButton)
if checkInternetConnection()
let objLocationTracker = LocationTracker.sharedInstance
objLocationTracker.fetchCurrentLocation({ (objLocation) -> (Void) in
self.loginWithTwitter(objLocation: objLocation)
SINGLETON.toast(read_Localizable("noInternet"),view: self.view)


see this

@@IBAction func btnTwitter_Clicked(sender:UIButton) you were added the additional @ in front of your button, check once ,

in swift3 we need to write the button action like

yourbuttonName.addTarget(self, action: #selector(yourVCName. btnTwitter_Clicked(_:)), for: .touchUpInside)

and call method as like

@IBAction func btnTwitter_Clicked(_ sender: UIButton){
   print("Button pressed