Value of type 'UITableView' has no member 'sectionHeaderTopPadding'

Why I am getting build error from Xcode 12.4 (simulator ios 14.x) for the following code?

    if #available(iOS 15.0, *) {
        myTableView.sectionHeaderTopPadding = 0.0 // error here
    }

The error was,

Value of type 'UITableView' has no member 'sectionHeaderTopPadding'

If ios 15 is not available Xcode is supposed to skip compiling this code. Isnt it?

3 answers

  • answered 2022-01-13 06:39 Pranay Chander

    This won't build as Xcode 12.4 is shipped with iOS14 and is not aware of the presence of "sectionHeaderTopPadding" in iOS 15. You will have to install Xcode 13 to successfully build this.

  • answered 2022-01-13 06:41 Muhammad Waqas

    Because xCode 12.x supports max iOS 14.x development, so how can your xCode know what is provided in iOS 15.x

    If you are working with a team member and your teammate have xCode 13.x then either you can update your xCode to use the this code, or you can comment this code and then build from your xCode (12.x).

  • answered 2022-01-13 06:51 Mohammad Irfan

    Update your XCODE version to 13

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum