Print quick variational parameter in Objective-C

I am currently working on a fast dynamic framework that will be used for the objective-c application.

I created this method (signature):

public init(buttons: ActionButton...) {
///code
}

However, this method is never available (visible) from an objective-c application using the framework. When adding

@objc

before the declaration of the xcode method throws an error

"The method cannot be marked as @objc because it has a variable parameter

So, if I understand correctly, fast variable parameters cannot be objective. So I ask the question: Is there another way (CVArgList?) To get the same functionality?

I know I can use arrays, but I would prefer not to use this function.

Thank.

+4
1

C Swift, . . Swift Cocoa Objective-C: API- C: Variadic .

. . Swift:

public class Test: NSObject {
    convenience public init(buttons: String...) {
        self.init(buttonArray: buttons)
    }

    public init(buttonArray: [String]) {

    }
}

ObjC .

@interface Test (ObjC)
- (instancetype) initWithButtons:(NSString *)button, ...;
@end

@implementation Test (ObjC)

- (instancetype) initWithButtons:(NSString *)button, ... {
    NSMutableArray<NSString *> *buttons = [NSMutableArray arrayWithObject:button];
    va_list args;
    va_start(args, button);

    NSString *arg = nil;
    while ((arg = va_arg(args, NSString *))) {
        [buttons addObject:arg];
    }

    va_end(args);
    return [self initWithButtonArray:buttons];
}

@end
+6

All Articles