I've put the following into a Playground to try and understand this and I just don't:
import Foundation
@objc protocol Sample {
var value: Int { get set }
func increase()
func decrese()
}
extension Sample {
func increase() {
value += 1
}
func decrease() {
value -= 1
}
}
class Test: Sample {
var value: Int = 0
}
The error appears next to the class
declaration for Test
saying:
Non-'@objc' method 'increase()' does not satisfy requirement of '@objc' protocol 'Sample'
If I re-declare increase()
and decrease()
in the class then the warning is silenced. Or also if I remove the declarations from the protocol. Could someone please explain?
EDIT
I do need an Objective-C class to conform to this protocol as well, hence the @objc
at the start.