【问题标题】:PayMill iOS SDK: Swift 1.1 > 1.2 compatibilityPayMill iOS SDK:Swift 1.1 > 1.2 兼容性
【发布时间】:2015-04-19 22:55:10
【问题描述】:

我在 Swift 项目中使用 PayMill's iOS SDK

我对他们的PMManager.initWithTestMode() 有疑问,请参阅docs here

此代码与 Swift 1.1 和 iOS 8.1 / 8.2 完美配合:

PMManager.initWithTestMode(testMode, merchantPublicKey: publicKey, newDeviceId: nil,
    { (success, error) -> Void in
        if success{
            println("successfully initialized PayMillSDK")
        }
        else{
            println("error during initialization")
        }
    }
)

它给了我以下错误:

调用中缺少参数标签init

在关闭之前添加init:会触发更多警告。

如何修改上述 sn-p 以兼容 iOS 8.3 / Swift 1.2?

非常感谢任何帮助!

【问题讨论】:

    标签: ios swift closures paymill


    【解决方案1】:

    问题是init 现在是保留关键字。所以在 Swift 中选择这个作为参数名是没有选择的。然而,在 Objective-C 中,这是可能的。

    幸好现在可以使用这种语法糖了:

    PMManager.initWithTestMode(testMode, merchantPublicKey: publicKey, newDeviceId: nil)
        { (success, error) -> Void in
            if success{
                println("successfully initialized PayMillSDK")
            }
            else{
                println("error during initialization")
            }
        }
    

    【讨论】:

    • 非常感谢,这非常有效。一切都完美编译,运行时也没有错误。再次感谢! :-)
    猜你喜欢
    • 1970-01-01
    • 2015-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多