Zum Inhalt springen

Force Unwrap And Cast (ARCH9196)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key swift.quality.force-unwrap · Severity warning · Category quality

Flags ! force unwraps, as! force casts and try! - crashes waiting for the case the type system warned about.

let name = user!.name
let vc = segue.destination as! DetailViewController
let data = try! load()
guard let user else { return }
guard let vc = segue.destination as? DetailViewController else { return }
let data = try load()

Use optional binding, as?, and propagate errors with try.