I have a variable named name with string "Magellan" that needs to be added to each VC's nameLabel.
In first VC:
var name = "Magellan"
First VC prepare for segue:
destination?.nameLabel.text = name!
destination?.name = name!
In second VC:
var name = String()
Second VC prepare for segue:
destination?.nameLabel.text = name!
destination?.name = name!
In second VC to go to third VC:
Error: Unexpectedly found nil unwrapping nameLabel.text
Error: Unexpectedly found nil unwrapping name
you have to change your
to
the difference of this is when you used the var name = String() you are assigning String class to your variable name while for var name : String = “” you are assigning empty value to your string type variable name.