I would like to set some properties of an Objective-C class instance to some Swift functions and I am getting an error that I do not understand, maybe something with the types is wrong:
Objective-C:
@interface MyWrapper : NSObject
@property (nonatomic) void(*f1)();
@property (nonatomic) void(*f2)(void*);
@end
Swift:
func saySomething1() {
print("Something 1")
}
func saySomething2(buf:UnsafeRawPointer) {
print("Something 2")
}
let x = MyWrapper()
x.f1 = saySomething1 // OK
x.f2 = saySomething2 // error: Cannot assign to property: 'x' is a 'let' constant
Changing let
to var
does not help (same error message).