1

I have no idea what i am getting wrong here, i am basically checking if a value is coming back nil then populate the UILabel with a standard number or else if the value comes back, i populate the UILabel with the value.

account.agent.ddi == "" || account.agent.ddi == nil ? self.ddiLabel.text = "02039909000" : self.ddiLabel.text =  account.agent.ddi
Cristik
  • 30,989
  • 25
  • 91
  • 127
sk123
  • 580
  • 1
  • 8
  • 29

2 Answers2

2

Since you're assigning to self.ddiLabel.text in both of the cases you can separate the assignment from the ?: operation, making the return type String in both cases

ddiLabel.text = account.agent.number == "" || account.agent.ddi == nil ? "02039909000" : account.agent.ddi
David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
1

It's heavy for the the compiler without ()

account.agent.ddi == "" || account.agent.ddi == nil ? ( self.ddiLabel.text = "02039909000" ) : ( self.ddiLabel.text =  account.agent.ddi)
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87