implement static method

Observer implement({
  1. required void observeValueForKeyPath_ofObject_change_context_(
    1. NSString,
    2. ObjCObject,
    3. NSDictionary,
    4. Pointer<Void>,
    ),
  2. bool $keepIsolateAlive = true,
})

Builds an object that implements the Observer protocol. To implement multiple protocols, use addToBuilder or objc.ObjCProtocolBuilder directly.

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

Implementation

static Observer implement({
  required void Function(
    NSString,
    objc.ObjCObject,
    NSDictionary,
    ffi.Pointer<ffi.Void>,
  )
  observeValueForKeyPath_ofObject_change_context_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(debugName: 'Observer');
  Observer$Builder.observeValueForKeyPath_ofObject_change_context_.implement(
    builder,
    observeValueForKeyPath_ofObject_change_context_,
  );
  builder.addProtocol($protocol);
  return Observer.as(builder.build(keepIsolateAlive: $keepIsolateAlive));
}