Faisal Syed Faisal Syed - 2 months ago 61
Objective-C Question

Method intrinsicContentSize() conflicts with getter from superclass

The following function in Swift 3 gives off a compiler error:

func intrinsicContentSize() -> CGSize {
return CGSize(width: 0.0, height: 55.0)
}


"Method 'intrinsicContentSize()' with Objective-C selector 'intrinsicContentSize' conflicts with getter for 'intrinsicContentSize' from superclass 'UIView' with the same Objective-C Selector"

How do I apply this function in Swift 3?

Answer

This is a property, not a method, so in Swift it's overridden using the property syntax rather than a getter method as it would be in Objective-C:

override var intrinsicContentSize: CGSize {
    return CGSize(width: 0.0, height: 55.0)
}
Comments