سؤال

What does this __attribute__((nonnull(2))) mean in the following method declaration?

 - (void)requestShareWithObjectId:(NSString *)object 
                       completion:(void (^)(NSString *likes, NSString *reposts))completion __attribute__((nonnull(2)));
هل كانت مفيدة؟

المحلول

It denotes that the Second parameter should not be a null pointer.

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

References

  1. NSHipster - __attribute__
  2. ARM
  3. Keil
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top