@available with pre-release versions of iOS - missing properties

I implemented a class like this:

class MapLayoutGuide: NSObject, UILayoutSupport { var insetLength: CGFloat = 0 init(insetLength: CGFloat) { self.insetLength = insetLength } var length: CGFloat { return insetLength } } 

Everything worked fine, but new changes appeared in the new version of iOS: Apple changelog .

So now I get 3 errors:

  • Protocol requires property 'topAnchor' with type 'NSLayoutYAxisAnchor' ,
  • Protocol requires property 'bottomAnchor' with type 'NSLayoutYAxisAnchor' ,
  • Protocol requires property 'heightAnchor' with type 'NSLayoutDimension' .

Looking at the implementation of UILayoutSupport , I see new variables:

 @available(iOS 9.0, *) var topAnchor: NSLayoutYAxisAnchor { get } @available(iOS 9.0, *) var bottomAnchor: NSLayoutYAxisAnchor { get } @available(iOS 9.0, *) var heightAnchor: NSLayoutDimension { get } 

My app is iOS 8.0+ . So the question is, what should I do with these values? I cannot set the @available flag, and I want the code to work with both iOS 8 and 9 , but I have to override it. There is no idea what to do with it.

The code used to work yesterday on Xcode Beta 1 , which one does not matter atm, since I want it to work with the current API not earlier.

+6
source share
1 answer

He worked after cleaning the project.

 @available(iOS 9.0, *) var topAnchor: NSLayoutYAxisAnchor { return NSLayoutYAxisAnchor() } @available(iOS 9.0, *) var bottomAnchor: NSLayoutYAxisAnchor { return NSLayoutYAxisAnchor() } @available(iOS 9.0, *) var heightAnchor: NSLayoutDimension { return NSLayoutDimension() } 
+5
source

Source: https://habr.com/ru/post/990015/


All Articles