Can we create a nullable / nonnull property in objective-c?

Is it possible to create a nullable / nonnull property in objective-c, if so, how?

+4
source share
2 answers

You can use qualifiers _Nullableand_Nonnull

@property (copy, nullable) NSString *name;
@property (copy, nonnull) NSArray *allItems;

nonnull: indicates that the pointer should / will never be zero. Pointers annotated with non-zero are imported into Swift as their optional base value (i.e., NSData).

nullable: indicates that the pointer may be null in normal practice. Imported into Swift as an optional value (NSURL?).

+3
source

_Nullable _Nonnull, . ( , const).

+5

Source: https://habr.com/ru/post/1612389/


All Articles