msgSend<T> function
Send a message to target
on GCD queues asynchronously using onQueue
.
target
should be an instance in iOS and macOS.
onQueue
is DispatchQueue.main
by default.
The message will consist of a selector
and zero or more args
.
Return value will be converted to Dart types.
Implementation
Future<T> msgSend<T>(Pointer<Void> target, SEL selector,
{List? args, DispatchQueue? onQueue}) async {
// Send message to global queue by default.
onQueue ??= DispatchQueue.global();
final completer = Completer<T>();
_msgSend(target, selector, args: args, onQueue: onQueue,
callback: (dynamic result) {
completer.complete(result);
});
return completer.future;
}