golang/go
x/mobile: Add support for callback blocks in ObjC reverse bindings with matching Go function signatures
开放
#35,967 创建于 2019年12月4日
FeatureRequestNeedsInvestigationhelp wantedmobile
仓库指标
- 星标
- (133,883 个星标)
- PR 合并指标
- (PR 指标待抓取)
描述
What version of Go are you using (go version)?
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
What did you do?
Attempted to use a function pointer as a block parameter in ObjC reverse bindings
What did you expect to see?
I hoped it would work
What did you see instead?
Compilation error: implicit type "void" not found
Assume the function:
import (
"ObjC/UserNotifications"
"ObjC/UserNotifications/UNUserNotificationCenter"
)
func testBinding() {
unc := UNUserNotificationCenter.CurrentNotificationCenter()
handler := func(settings *UserNotifications.UNNotificationSettings) {
// TODO
}
unc.GetNotificationSettingsWithCompletionHandler(handler)
}
Getting reference to the UNUserNotificationCenter singleton compiles and works. However, simply referencing the GetNotificationSettingsWithCompletionHandler function causes a compiler error when trying to understand the method signature looking for a completion handler.
GOMOBILE=/Users/dave/go/pkg/gomobile
WORK=/var/folders/4j/j8tb1q2s4kd3rdn0v_hzh_6m0000gn/T/gomobile-work-846542795
GOOS=darwin CGO_ENABLED=1 /Users/dave/go/bin/gobind -lang=go,objc -outdir=$WORK -tags=ios poc/poc
rm -r -f "$WORK"
gomobile: /Users/dave/go/bin/gobind -lang=go,objc -outdir=/var/folders/4j/j8tb1q2s4kd3rdn0v_hzh_6m0000gn/T/gomobile-work-846542795 -tags=ios poc/poc failed: exit status 1
2019/12/04 13:30:59 implicit type "void" not found