Reputation: 509
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.
Thanks!
Upvotes: 0
Views: 578
Reputation: 3318
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.
Upvotes: 1
Reputation: 299455
input
is UITextField!
. It's probably nil
, which probably means you forgot to connect it in Interface Builder.
Upvotes: 1