简体   繁体   中英

Method declaration is different from general declaration

When debugging i found this method.

   - (void)sendPublicEvent:(NSInteger)type, ... KNCONTANT_VALUE

The method declaration is different from generation method declaration.

I do not understand why it postfix after type ,... KNCONTANT_VALUE` I want to know why method declaration is different,any one advice me! @thanks in Advance

This method is taking a variable argument.

See this example:

In .h

-(void)variableArgument:(NSString *)string, ...;

In .m

- (void)variableArgument:(NSString *)string, ... {
  va_list args;
  va_start(args, string);
  NSLogv(string, args);
  va_end(args);
}

And KNCONTANT_VALUE is showing that this should be your last constant value after the Integer values.

When we deal with strings we use : -(void)variableArgument:(NSString *)string, ... NS_REQUIRES_NIL_TERMINATION;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM