dazza500009/09/2020, 5:39 PM
Sam09/09/2020, 7:24 PM
entries to give it a friendly Swift name.
Here’s a heavily redacted example.
__attribute__((swift_name("MyClass"))) @interface MyCo_myModuleMyClass : NSObject - (instancetype)initWithChar:(char)value; + (instancetype)myClassWithChar:(char)value; @end;
declares the class. In this case it inherits from NSObject. Methods that start with a
are instance methods and methods with a
are static methods. In swift you would declare a variable of this type using:
My ObjC is a bit rusty so this syntax may be slightly off but it should be something like:
let foo: MyClass = MyClass(char: "x")
MyCo_myModuleMyClass foo = [[MyCo_myModuleMyClass alloc] initWithChar: "x"];
dazza500009/09/2020, 7:29 PM
Sam09/10/2020, 4:57 PM
dazza500009/10/2020, 6:19 PM
Sam09/10/2020, 9:53 PM
if the bar method exists on the foo object or just error out. You could always provide a factory function like