How does a non optional value obtain a nil value?

后端 未结 4 1305
暖寄归人
暖寄归人 2021-02-13 06:18

The Apple documentation TN2151 says this for a possible cause of a EXC_BREAKPOINT / SIGTRAP:

a non-optional type with a nil valu

4条回答
  •  失恋的感觉
    2021-02-13 06:49

    Happens when interoperating with Objective C. An objc-method could be annotated as nonnull, but nothing prevents it from returning nil anyways. The compiler catches only the most obvious cases and even then it only produces warnings (e.g. when you blatently return nil; in a method that is specified as not returning nil.)

提交回复
热议问题