You're setting the defaults but you're not reading back out of it:
if let string = UserDefaults.standard.object(forKey: "myKey") as? String { textext.text = string } Or as pointed out, since the textfields text is optional:
textext.text = UserDefaults.standard.object(forKey: "myKey") as? String