Can someone elaborate why is nonnull
introduced in iOS 9 ?
For example, the NSArray
method + (instancetype)array;
is now + (
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.