2
 override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if saveButton === sender {


        var patientNumber = loadPatients()

        let id = String(Int((patientNumber?.count)!) + 1)
        let name = patientNameTextField.text ?? ""
        let location = patientLocationTextField.text ?? ""
        let status = "Ok"
        let bluetoothAddress = peripheralKeyArray[pickedAddressRow]

        // Set the meal to be passed to MealTableViewController after the unwind segue.
        patient = Patient(id: id, name: name, location: location, status: status, bluetoothAddress: bluetoothAddress)

        //Kill Timer before view closed
        timer.invalidate()
    }
}

The problem's are

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

and

if saveButton === sender {

Cannot override instance method parameter of type 'Any?' with non-optional type 'Any'

Binary operator '===' cannot be applied to operands of type 'UIBarButtonItem!' and 'Any'

I do not understand these errors even after searching about them. Would really appreciate it if someone could simplify an explanation for me. :) Thank you!

Alexander
  • 59,041
  • 12
  • 98
  • 151
vevek
  • 51
  • 1
  • 3
  • 1
    clear derived data file and run it again. for locatin of derived data file you can refer, http://stackoverflow.com/questions/39657436/alamofire-compiled-with-older-version-of-swift-language-2-0-than-previous-file/39657541#39657541. @vevek – KAR Sep 23 '16 at 17:16
  • `sender` is an optional. `Any?` and `Any` are not the same thing. Unwrap `sender`. – Daniel Storm Sep 23 '16 at 17:18
  • @DanielStorm You can't compare two `Any` using `===` either. – kennytm Sep 23 '16 at 17:21
  • @KAR I did that, unfortunately it did not solve the error.. – vevek Sep 24 '16 at 18:49
  • @DanielStorm I don't understand that. I experimented with unwrapping the sender, however it didn't work. Currently I changed the code to func prepare(for segue: UIStoryboardSegue, sender: UIButton) { if saveButton === sender { however I get this error now. /Users/vevek/AscentHome/AscentHome/PatientViewController.swift:31:57: Cannot override instance method parameter of type 'Any?' with non-optional type 'Any' – vevek Sep 24 '16 at 18:51
  • @Hamish Thank you so much! That solved the problem. :) – vevek Sep 24 '16 at 18:55

0 Answers0