0

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!

nhgrif
  • 61,578
  • 25
  • 134
  • 173
Camillo
  • 544
  • 1
  • 6
  • 24

1 Answers1

1

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")
        }
    }
vrwim
  • 13,020
  • 13
  • 63
  • 118
  • Thanks a lot, this worked perfectly. Everything compiles perfectly, and no errors in runtime as well. Thanks again! :-) – Camillo Apr 20 '15 at 21:17