I would like to emulate the functionality of [NSArray arrayWithObjects:] , which allows me to enter arguments as follows: [MyClass doSomethingWithObjects: @"str1",@"str2",nil] . Assuming this is possible, how can I declare this?
[NSArray arrayWithObjects:]
[MyClass doSomethingWithObjects: @"str1",@"str2",nil]
Found to be explained here: http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html
//interface: - (void)foo:(NSString *)firstString, ... NS_REQUIRES_NIL_TERMINATION; //implementation: - (void)foo:(NSString *)firstArg, ... { va_list args; va_start(args, firstArg); for (NSString *arg = firstArg; arg != nil; arg = va_arg(args, NSString*)) { [self bar:arg]; } va_end(args); }
Source: https://habr.com/ru/post/888760/More articles:How to split a string into two using character separator in C #? - stringHow can I put the tag aside, which side should I continue? - html5Checking date and time on rails - validationCreate a 2D barcode (e.g. QR code, data matrix, PDF417) on iPhone and Android - androidTextSwitcher throws a "more than 2 views" error when calling setFactory () - androidPassing a block for a tag helper in rails3 - ruby-on-railsWhat is the best algorithm for finding the sum of all elements in an arbitrary footer - algorithmScroll scrollviewer to the top via viewmodel - scrollWhy is there always some noise in the freetype rendered text? - cUsing Perl memory with a map and file - memory-managementAll Articles