LoginSignup
0
1

More than 3 years have passed since last update.

Fatal error: Unexpectedly found nil while unwrapping an Optional value ってよくあるやつでた

Posted at

Fatal error: Unexpectedly found nil while unwrapping an Optional valueとでたのでなんとかしたい

ViewController.swift
if req_orders.childOrderState.rawValue == "COMPLETED" {
           print("Get orders !: \(response)")
}
Fatal error: Unexpectedly found nil while unwrapping an Optional value

。。。。。。。。
だめ

ViewController.swift
if req_orders.childOrderState!.rawValue == "COMPLETED" { //!入れてみた
           print("Get orders !: \(response)")
}
Fatal error: Unexpectedly found nil while unwrapping an Optional value

。。。。。。。。
だめ

解決

ViewController.swift
if req_orders.childOrderState?.rawValue == "COMPLETED" { //?にしてみた
           print("Get orders !: \(response)")
}
Build Succeed

いけた! (原因はわかりません、オプショナルもxcodeの指示通りやってればなんとかなるで乗り切ってるから基本を勉強しないと、、、、)

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1