valueWithStruct<T extends NativeStruct> static method
Stands for -[NSValue valueWith{StructName}]
in iOS and macOS.
StructName
is struct
.runtimeType.toString() by default. You can also pass in an alias:
See the implementation of valueWithRange
in NSValueRangeExtensions.
Implementation
static NSValue valueWithStruct<T extends NativeStruct>(T struct,
{String? structAlias}) {
String selName = 'valueWith${structAlias ?? struct.aliasForNSValue}:';
NSObject result =
type(of: NSValue).performSync(SEL(selName), args: [struct]);
NSValue value = NSValue.fromPointer(result.pointer);
value.raw = struct;
return value;
}