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

后端 未结 6 1360
暗喜
暗喜 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:58

    You can also do like this:

    - (id __nullable)methodWithArg:(NSString * __nullable)arg1
                            andArg:(NSString * __nonnull)arg2
                 completionHandler:(void (^ __nonnull)(NSArray * __nonnull results, NSError * __nullable error))completionHandler;
    

    It only depends which syntax you like more.

提交回复
热议问题