gpt4 book ai didi

objective-c - 使用 __attribute__((nonnull(2))) 声明方法

转载 作者:搜寻专家 更新时间:2023-10-30 19:47:37 25 4
gpt4 key购买 nike

__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.

引用资料

  1. NSHipster - __attribute__
  2. ARM
  3. Keil

关于objective-c - 使用 __attribute__((nonnull(2))) 声明方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23300746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com