【问题标题】:Selector for Swift method containing one named parameter包含一个命名参数的 Swift 方法的选择器
【发布时间】:2019-12-05 17:15:36
【问题描述】:

我有以下 Swift 方法:

@objc public func theme(withIdentifier identifier: String?) -> Theme? {
    [...]
}

我希望创建一个 Xamarin 绑定到它,但我无法确定正确的选择器。我试过了:

[Export("theme:")]
Theme Theme(string identifier);

但我明白了:

-[TKThemeManager 主题:]:无法识别的选择器发送到实例 0x6000025b4680

我已经试过了:

[Export("theme:withIdentifier:")]
Theme Theme(string identifier);

这给出了:

注册商发现方法中的签名不匹配 'MyApp.Mac.ThemeKit.ThemeManager.Theme' - 选择器 'theme:withIdentifier:' 表示该方法有 2 个参数,而 托管方法有 1 个参数。

这当然是真的。

调用此方法的正确选择器是什么?

【问题讨论】:

    标签: swift xamarin


    【解决方案1】:

    正确的选择器是

    themeWithIdentifier:
    

    【讨论】:

    猜你喜欢
    • 2015-02-04
    • 2011-06-19
    • 1970-01-01
    • 2016-02-12
    • 1970-01-01
    • 2014-12-16
    • 1970-01-01
    • 2018-10-22
    • 1970-01-01
    相关资源
    最近更新 更多