1

Fatal error: unexpectedly found nil while unwrapping an Optional value
I checked that ticket that didn't help me:

What does "fatal error: unexpectedly found nil while unwrapping an Optional value" mean?

  "CODE_SUPLEMENT7": form.csupplement7! != nil ? form.csupplement7! : "",

I try to avoid that mistake, but it says "Comparing non-optional value of type String to nil always return true."

How to find the good type String with the capability to accept the String ? (because my code is all based on it...)

enter image description here

Thanks in advance.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
ΩlostA
  • 2,501
  • 5
  • 27
  • 63
  • 1
    change `form.csupplement7! != nil ? form.csupplement7! : ""` to `form.csupplement7 ?? ""`. You should google about the `??` nil coalescing operator – Leo Dabus Nov 08 '17 at 18:13

1 Answers1

2

Your problem is your use of ! just before the !=.

It should be:

form.csupplement7 != nil ? form.csupplement7! : ""

But even better is to use ??:

form.csupplement7 ?? ""
rmaddy
  • 314,917
  • 42
  • 532
  • 579