4

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)));
jscs
  • 63,694
  • 13
  • 151
  • 195
user3574157
  • 79
  • 1
  • 4

1 Answers1

1

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
Midhun MP
  • 103,496
  • 31
  • 153
  • 200