Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handle _Nonnull or Nullable with multi-level pointer type

How to associate nullability keywords with multi-level pointer types in following declaration for (NSError **)error?

- (void)loadSessionForUserId:(nonnull NSString *)userId error:(NSError **)error { ... }

I want to make error nullable and get rid of “Pointer is missing a nullability type specifier (__nonnull or __nullable)”

Error variant with Xcode11: nullability keyword 'nullable' cannot be applied to multi-level pointer type 'NSError *__autoreleasing _Nullable *'

enter image description here

like image 230
lal Avatar asked Sep 18 '25 18:09

lal


1 Answers

If you are getting a warning, or error if treat-warning-as-error is on for project, on Xcode 9. Use this format for multi-level pointers:

Solution:

error:(NSError *_Nullable* _Nullable)error

Other error variations:

a) With error:(NSError ** _Nonnull)error Results in compile time error Nullability keyword 'nullable' cannot be applied to multi-level pointer type 'NSError *__autoreleasing *’

b) with error:(NSError * _Nonnull *)error Results in compile time error Pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)

c) with error:(NSError ** _Nullable)error Results in compile time error Pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)

Open Radar for NSError** without a nullability type shows as a warning which can't be suppressed http://www.openradar.me/21766176

like image 143
lal Avatar answered Sep 23 '25 10:09

lal