Nat
Nat

Reputation: 12948

@available with pre-available iOS versions - missing properties

I've implemented such class:

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

Everything was working fine, however there were new changes introduced with new iOS version: Apple changelog.

So now I'm receiving 3 errors:

Looking into UILayoutSupport implementation I can 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 can't set @available flag and I want the code to work both with iOS 8 and 9, but I have to override it. No conception what to do with it.

The code used to work yesterday on Xcode Beta 1, what ofc doesn't matter atm as I want it to work on current API not previous.

Upvotes: 6

Views: 3508

Answers (1)

Nat
Nat

Reputation: 12948

It 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()
}

Upvotes: 7

Related Questions