Nagar Nagar - 1 month ago 11
Swift Question

Ambiguous use of title - Xcode 9 beta

Xcode 9 beta compiler shows the following error for the

navigationItem.title
and also for the
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 for solving this issue?

Answer Source

UPDATE:

Just use this code:

navigationItem.titleLabel.text = "text"

OLD ANSWER:

It happen because you use third party library which extends UINavigationItem class and reimplements property title. So, this library conflict with UIKit.

Solution:

Just use

title

instead of

navigationItem.title

Or remove extension of UINavigationItem class in the third-party library. The name of this library you can see in the issue navigator:

error

For MATERIAL solution is:

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

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