0

I am trying to make a ios app using xcode. I don't want to use the UIBarButton because I don't want the users to be able to go back. I tried following this previous post: Using UIButton to navigate between views But it was not working for me.I have this for code:

`//MARK: Navigation
@IBAction func adClosure(_ sender: UIButton) {
    self.prepareForSegue(segue: "adToMain", sender: self)

}

func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
    if segue.identifier == "adToMain" {

    }
}

The transition segue is called adToMain in my Main.storyboard. I have an error on the line with self.prepareForSegue(segue: "adToMain", sender: self) because of mismatching argument types.

Thank you for the help in advance.

JaguarJmn
  • 7
  • 6
  • It's `prepare(for:)` since Swift 3. – Tamás Sengel Apr 13 '18 at 15:53
  • Just start typing prepare and Xcode will itself suggest the list of functions available. self.prepare(for: <#T##UIStoryboardSegue#>, sender: <#T##Any?#>) is the one you are looking for. – Nitish Apr 13 '18 at 15:56
  • An advice : Don't copy paste the code. self.prepareForSegue(segue: "adToMain", sender: self) was in old Swift versions. – Nitish Apr 13 '18 at 15:57
  • What's the version of Swift that you are using? Does the compiler suggest any fix? – Ahmad F Apr 13 '18 at 16:04
  • @AhmadF I am doing it in xcode, but from my understanding it uses swift, so the newest version. – JaguarJmn Apr 13 '18 at 16:06

0 Answers0