I want to set the title, so I used: titleBar.topItem?.title = user!.name, where titleBar is a navigationBar.
@IBOutlet weak var titleBar: UINavigationBar!
but it keeps giving me fatal error; Here is my code: when I did print (user!.name), it will give me optional("why"), where "why" is the value of user!.name.
var user:User! {
didSet{
// titleBar.topItem?.title = user!.name
print("hhh")
print("this is the name:",user!.name)
print("hello")
print("why???")
}
}
Even when I tried to use the user.name in a different function but in the same view controller file, it will still give me nil.
print("sent to person: ", self.user?.name)
Can someone help me with this?