Can someone elaborate why is nonnull
introduced in iOS 9 ?
For example, the NSArray
method + (instancetype)array;
is now + (
They have made sure that wherever the type is not-nullable it is now a nonnull
type.
Like earlier NSMutableArray addObject
method was
- (void)addObject:(ObjectType)anObject
and now it has been changed to
- (void)addObject:(ObjectType nonnull)anObject
So it means you cannot pass a null object (nil
) to this method. Same way, in your case
+ (instancetype nonnull) array
method will never return nil
.
Reference: https://developer.apple.com/swift/blog/?id=25