Ambiguous use of the name - Xcode 9 beta

Xcode 9 beta compiler shows the following error for navigationItem.title

as well as self.navigationController?.navigationBar.topItem?.title

:

Ambiguous use of 'title'

This is my code:

self.title = BMLocalized("Select Number of Passengers")
navigationItem.title = navigationTitleString // here showing error
submitButton.setTitle(submitButtonTitle, for: .normal)

      

error screenshot

Can anyone help with this issue?

+3


source to share


3 answers


UPDATE:

Just use this code:

navigationItem.titleLabel.text = "text"

      

OLD ANSWER:

This is because you are using a third party library that extends the UINavigationItem class and reuses the property title. So this library conflicts with UIKit.

Decision:

Just use

title

      



instead

navigationItem.title

      

Or remove the UINavigationItem class extension in the third party library. You can see the name of this library in the problem navigator:

error

For MATERIAL solution:

remove these lines from Material -> Core -> NavigationItem.swift:

public var title: String? {
    get {
        return titleLabel.text
    }
    set(value) {
        titleLabel.text = value
        navigationItem.reload()
    }
}

      

+1


source


Currently, instead of changing the source code, you can also use this:



navigationItem.titleLabel.text = "foo"

      

+2


source


Just use

self.title = "title_name"

instead of both, and if you use both, then they will swap for each other.

0


source







All Articles