I am using PayMill's iOS SDK in a Swift project.
I have an issue with their PMManager.initWithTestMode()
, see docs here:
This code worked perfectly with Swift 1.1 and 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")
}
}
)
It gives me the following error:
Missing argument label
init
in call
Adding init:
before the closure will trigger more warnings.
How can I modify the above snippet to allow compatibility with iOS 8.3 / Swift 1.2?
Any help is much appreciated!
The problem is that init
is now a reserved keyword. So there is no option in picking this as parameter name in Swift. In Objective-C however, this was possible.
Now thankfully it is possible to use this syntactic sugar:
PMManager.initWithTestMode(testMode, merchantPublicKey: publicKey, newDeviceId: nil)
{ (success, error) -> Void in
if success{
println("successfully initialized PayMillSDK")
}
else{
println("error during initialization")
}
}