Using nullability with block APIs

I have an API

+ (void)getTheThing:(nonnull void (^)(NSString * __nullable thing, NSError * __nullable error))completion;

(Syntax taken from here )

But when you go to use it and use the autocomplete of the Xcode block, it automatically completes this:

[MyAPI getTheThing:^nonnull void(NSString * __nullable, NSError * __nullable) {
    <#code#> 
}];

Which gives errors for nonnullthat are not recognized, the fact of the absence of argument names, etc ....

Any idea what is going on ?: S I declare this to be wrong? This material is fairly new, and the documentation is not really complete: /

+4
source share
1 answer

Any idea what is going on?

It is broken http://www.openradar.me/20835509

I declare that it is wrong?

You could annotate the blocks as follows:

+ (void)getTheThing:(void (^__nonnull)(NSString * __nullable thing, NSError * __nullable error))completion;

:

[MyAPI getTheThing:^(NSString * __nullable, NSError * __nullable) {
    <#code#> 
}];

. , .

,

llvm , .

+5

All Articles