Good evening everyone.

I have such a plan of error, (I don’t understand it that way)

In general, I announced UILabel and screwed it as IBAOutlet

I give it a value, but it gives a fatal error. enter image description here

  • What mistake? How do you set the value? - VAndrJ pm
  • Who calls the setVariableElement function and when? - Max Mikheyenko
  • solved a problem ! - jcmax

1 answer 1

problem solved. The thing is that when I am in the TableViewController in the list of elements and select some element, it works

// метод который определяется перед переходом override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { // куда мы направляемся if let controller = segue.destinationViewController as? showCellController { let element = "\(sender)" print("element to send: \(element)") controller.text = element as String //controller.setVariable(element) } } 

which causes another class that is tied up under another controller in which that label is located, and as IBA Outlet has not yet been announced, although the class itself has already been declared, it gives an error.

The solution is to first create a variable in which the data will be added, and then via ViewDidLoad (), call the method that initially needed to be called and give the outlet a string value.