I am trying to modify the placeholder text of a text field in Swift. However there is an error about "fatal error: unexpectedly found nil while unwrapping an Optional value." I am not sure why this would be nil.
Any chance your input is not connected in interface builder?
– DevAndArtist
2 Answers
1
votes
input is UITextField!. It's probably nil, which probably means you forgot to connect it in Interface Builder.
1
votes
Since you have weak pointer I think you should use ? and use it again to unwrap your variable.
@IBOutlet weak var input: UITextField?
input?.placeholder = "some text";
But as someone already said, you probably haven't connected the IBOutlet.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more
input
is not connected in interface builder? – DevAndArtist