Skip to content

[ffigen] Obj-C protocols: static getter can't be accessed through an instance? #2492

@mhernz

Description

@mhernz

Maybe this is a silly question. I'm calling a method in Objective-C that returns an NSArray of objects conforming to the following protocol:

https://github.com/maplibre/maplibre-native/blob/main/platform/darwin/src/MLNFeature.h

Then I want to access @property (nonatomic, copy) id identifier on those objects, but I get a linter error:

    final query = _mapView
        .visibleFeaturesAtPoint$1(
          point.toCGPoint(),
          inStyleLayersWithIdentifiers: NSSet.of(layerIds?.map((s) => s.toNSString()) ?? []),
        );
    final features = query.map(MLNFeature.castFrom);
    return features.map((f) => RenderedFeature(
      id: f.identifier,
         // ^ The static getter 'identifier' can't be accessed through an instance.
         //   Try using the class 'MLNFeature' to access the getter.
    )).toList();

And the static member MLNFeature.identifier is of type ObjCProtocolMethod<ObjCObjectBase? Function()> which I cannot figure out how to call on a particular object.

Could somebody walk me through how to access this property?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions