Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
[ad_1]
There isn’t any basic assemble to silence deprecation warnings in Swift, however there’s a workaround that may be utilized in lots of circumstances.
For instance you could have a way getLatestImage()
on class Foo
which makes use of deprecated strategies/courses.
Use @obtainable
as Daniel Thorpe described to silence all of the warnings inside the strategy:
@obtainable(iOS, deprecated: 9.0)
func getLatestImage() -> UIImage? {
...
}
Now you want to name the strategy getLatestImage()
with out having a deprecation warning. You may obtain that by first defining a protocol and an extension:
non-public protocol GetLatestImage {
func getLatestImage() -> UIImage?
}
extension Foo: GetLatestImage {}
After which name the strategy with out a deprecation warning.
If foo
is an occasion of Foo
:
(foo as GetLatestImage).getLatestImage() // no deprecation warning
If you wish to name a static property/perform of Foo:
(Foo.self as GetLatestImage.Sort).someStaticProperty
The result’s you could have Swift code that makes use of deprecated API with none deprecation warnings.
[ad_2]