How to use nonnull and nullable Objective-C keywords in block-based API method

后端 未结 6 1377
暗喜
暗喜 2020-12-22 22:13

Consider the following method

- (void)methodWithArg:(NSString *)arg1 andArg:(NSString *)arg2 completionHandler:(void (^)(NSArray *results, NSError *error))co         


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 22:45

    From apple developer blog: The Core: _Nullable and _Nonnull

    you can use the non-underscored forms nullable and nonnull immediately after an open parenthesis, as long as the type is a simple object or block pointer.

    The non-underscored forms are nicer than the underscored ones, but you’d still need to apply them to every type in your header.

提交回复
热议问题