I define a custom struct in Objc
typedef struct {
int a;
int b;
} MyStruct;
In Objc I can convert the struct to NSValue use
MyStruct struct = {0};
NSValue *value = [NSValue value:&struct withObjCType:@encode(MyStruct)];
But how can I do this in Swift?
Somewhere in your Objective-C code add a function like
and make it available to Swift code via a bridging header. Then in your Swift code you can do, for example, the following:
If you want to retrieve the value: