implementAsBlocking static method

NSURLConnectionDelegate implementAsBlocking({
  1. void connection_didFailWithError_(
    1. NSURLConnection,
    2. NSError
    )?,
  2. bool connectionShouldUseCredentialStorage_(
    1. NSURLConnection
    )?,
  3. void connection_willSendRequestForAuthenticationChallenge_(
    1. NSURLConnection,
    2. NSURLAuthenticationChallenge
    )?,
  4. bool connection_canAuthenticateAgainstProtectionSpace_(
    1. NSURLConnection,
    2. NSURLProtectionSpace
    )?,
  5. void connection_didReceiveAuthenticationChallenge_(
    1. NSURLConnection,
    2. NSURLAuthenticationChallenge
    )?,
  6. void connection_didCancelAuthenticationChallenge_(
    1. NSURLConnection,
    2. NSURLAuthenticationChallenge
    )?,
  7. bool $keepIsolateAlive = true,
})

Builds an object that implements the NSURLConnectionDelegate protocol. To implement multiple protocols, use addToBuilder or objc.ObjCProtocolBuilder directly. All methods that can be implemented as blocking listeners will be.

If $keepIsolateAlive is true, this protocol will keep this isolate alive until it is garbage collected by both Dart and ObjC.

Implementation

static NSURLConnectionDelegate implementAsBlocking({
  void Function(NSURLConnection, objc.NSError)? connection_didFailWithError_,
  bool Function(NSURLConnection)? connectionShouldUseCredentialStorage_,
  void Function(NSURLConnection, NSURLAuthenticationChallenge)?
  connection_willSendRequestForAuthenticationChallenge_,
  bool Function(NSURLConnection, NSURLProtectionSpace)?
  connection_canAuthenticateAgainstProtectionSpace_,
  void Function(NSURLConnection, NSURLAuthenticationChallenge)?
  connection_didReceiveAuthenticationChallenge_,
  void Function(NSURLConnection, NSURLAuthenticationChallenge)?
  connection_didCancelAuthenticationChallenge_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(
    debugName: 'NSURLConnectionDelegate',
  );
  NSURLConnectionDelegate.connection_didFailWithError_.implementAsBlocking(
    builder,
    connection_didFailWithError_,
  );
  NSURLConnectionDelegate.connectionShouldUseCredentialStorage_.implement(
    builder,
    connectionShouldUseCredentialStorage_,
  );
  NSURLConnectionDelegate
      .connection_willSendRequestForAuthenticationChallenge_
      .implementAsBlocking(
        builder,
        connection_willSendRequestForAuthenticationChallenge_,
      );
  NSURLConnectionDelegate.connection_canAuthenticateAgainstProtectionSpace_
      .implement(builder, connection_canAuthenticateAgainstProtectionSpace_);
  NSURLConnectionDelegate.connection_didReceiveAuthenticationChallenge_
      .implementAsBlocking(
        builder,
        connection_didReceiveAuthenticationChallenge_,
      );
  NSURLConnectionDelegate.connection_didCancelAuthenticationChallenge_
      .implementAsBlocking(
        builder,
        connection_didCancelAuthenticationChallenge_,
      );
  builder.addProtocol($protocol);
  return NSURLConnectionDelegate.castFrom(
    builder.build(keepIsolateAlive: $keepIsolateAlive),
  );
}