0

I am setting a optional property from previous view controller while pushing but even after optional binding its printing optional character in console. Here is my code

if let otp = self.confirmationCode {
    print(otp)        
}

It give output as follows:

"Optional(460207)"

What I am doing wrong ?

Luca Angeletti
  • 58,465
  • 13
  • 121
  • 148
Vikas
  • 914
  • 7
  • 19

1 Answers1

1

You are properly unwrapping the optional value.

So if you still find Optional... in the output String, my guess is the original value self.confirmationCode does contain this text Optional(460207).

This means you also need to unwrap the value somewhere else.

Luca Angeletti
  • 58,465
  • 13
  • 121
  • 148