What is nonnull in objective C?

后端 未结 4 469
一向
一向 2021-02-05 09:49

Can someone elaborate why is nonnull introduced in iOS 9 ?

For example, the NSArray method + (instancetype)array; is now + (

4条回答
  •  迷失自我
    2021-02-05 10:56

    nonnull is keyword which notify compiler that the value returned by object/parameters will never be nil.

    In general, you should look at nullable and nonnull roughly the way you currently use assertions or exceptions: violating the contract is a programmer error. In particular, return values are something you control, so you should never return nil for a non-nullable return type unless it is for backwards-compatibility.

提交回复
热议问题