How do I make a protocol method appear as deprecated for someone implementing the protocol? I've tried using @available
as shown below, but there is no warning shown in Xcode when implementing the protocol method.
protocol TestDelegate {
@available(*, deprecated, message: "Don't use this anymore")
func myMethod() -> Bool
}
extension ViewController: TestDelegate {
func myMethod() -> Bool {
return true
}
}
About attributes
@objc
protocol TestDelegate {
@available(iOS, unavailable)
func myMethod1() -> Bool
@available(iOS, unavailable, message: "Don't use this anymore")
func myMethod2() -> Bool
@available(iOS, unavailable, renamed: "myMethod4()")
func myMethod3() -> Bool
@available(iOS, obsoleted: 10.0)
func myMethod4() -> Bool
@available(swift, introduced: 3.0, obsoleted: 4.2)
func myMethod5() -> Bool
@available(iOS, introduced: 8.0, obsoleted: 11.0)
func myMethod6() -> Bool
}
extension ViewController: TestDelegate {
func myMethod1() -> Bool { return true }
func myMethod2() -> Bool { return true }
func myMethod3() -> Bool { return true }
func myMethod4() -> Bool { return true }
func myMethod5() -> Bool { return true }
func myMethod6() -> Bool { return true }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With