__attribute__((nonnull(2)))
在下面的方法声明中是什么意思?
- (void)requestShareWithObjectId:(NSString *)object
completion:(void (^)(NSString *likes, NSString *reposts))completion __attribute__((nonnull(2)));
最佳答案
表示第二个参数不能为空指针。
__attribute__((nonnull))
This function attribute specifies function parameters that are not supposed to be null pointers. This enables the compiler to generate a warning on encountering such a parameter.
Syntax
__attribute__((nonnull(arg-index, ...)))
Where arg-index, ... denotes the argument index list.
If no argument index list is specified, all pointer arguments are marked as nonnull.
引用资料
关于objective-c - 使用 __attribute__((nonnull(2))) 声明方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23300746/