You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's an unfortunate limitation of id-as-Any that we can't dynamically bridge ObjC blocks back and forth between closures if we don't statically know that the elements are closures at compile time. You can make the dictionary have [String: PSPDFRenderDrawBlock] type instead of [String: Any] type, or if it needs to be Any, assign explicitly @convention(block) values into it as you noted.
Environment
Xcode 9.2, Swift 4.0.3
Additional Detail from JIRA
md5: 3454906c1c80a880911892efb72c45b0
Issue Description:
Consider this ObjC block:
that is imported to Swift as (notice no @convention(block) here)
and stored in Dictionary on Swift side:
next, the `dict` is passed to the ObjC method as an argument of `NSDictionary<NSString, id>` type.
So far so good, everything compiles and works.
Now, when I try to retrieve the closure on the ObjC side and use it (call it). It crashes in runtime.
now, trying to use `value` it will crash of course.
The known workaround is to specify @convention(block) manually and unsafeBitCast() to AnyObject. See: https://stackoverflow.com/a/32787157/699944 for complete problem and example
The text was updated successfully, but these errors were encountered: