Closed stuartmorgan closed 1 month ago
Oh, a much more common use case for this would be respondsToSelector:
for optional protocol methods.
I'll make registerName
public and maybe rename it. Might also be convenient to add a string extension method: "foo:bar:".toSelector()
. A heavier change would be to add some sort of Selector
class to wrap Pointer<ObjCSelector>
, but I don't see a need for it, and this would require special casing in ffigen to use the wrapper class in place of the raw pointer.
Trying to convert some
CADisplayLink
code to Dart, I realized that it wasn't obvious how to interact with APIs that use thetarget:selector:
pattern (like+[CADisplayLink displayLinkWithTarget:selector:
). Since there are no docs for it, I generated it and looked at the output, and saw that the type isffi.Pointer<objc.ObjCSelector>
. Okay, so how do I make one? Jumping to the definition (inpkg:objective_c
) just gives me:Which is not helpful. The only answer I'm aware of to that question is
pkg:objective_c
'sregisterName
, but:registerName
's (only) documentation is/// Only for use by ffigen bindings.
.While this isn't a super common pattern in Apple SDKs, especially since newer code generally uses blocks instead, it is around, so we should have a clear support path for it.