Well, I need to add NFC functionality to a project and for this I am using CoreNFC. There is a condition that I need to add NFC functions using extension as below:
extension scanVC: NFCNDEFReaderSessionDelegate {
func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
}
func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
}
}
and rest of the code of view controller scanVC is also implemented using extensions like so:
extension scanVC {
override func viewDidLoad() {
super.viewDidLoad()
//viewDidLoad code here
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//viewWillAppear Code here
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// viewWillDisappear code here
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
//viewDidDisappear code here
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// code here
}
}
extension scanVC: SubmitForm {
// some other functionalities
}
// *** main class with some variable and outlets declaration ***
class scanVC: UIViewController {
@IBOutlet var headerScanLabel: UILabel!
@IBOutlet var scanView: UIView!
@IBOutlet var scanLabel: UILabel!
@IBOutlet var submitBtn: UIButton!
}
well now the problem is I need to declare one or more session variables in this main scanVC, but when I declare it gives me an error relating @available as: " 'NFCReaderSession' is only available on iOS 11.0 or newer " if I fix it adding "@available(iOS 11.0, *)" to its enclosing class then the extension with viewdidload,viewWillappear etc gives this error :
"Overriding 'viewDidLoad' must be as available as declaration it overrides"
I have spent almost a day to fix but nothing worked... any suggestion?? Xcode 10.2, swift 4. thanks!!