0
votes

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.

enter image description here

Thanks!

2
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.