1

I've got a Swift function that has a default parameter.

class Derp: NSObject{
    @objc(derp:derpsalot:)
    func derp(derpington: Int, derpsalot: Double = 0.0){

    }
}

Is there any way to have this imported into Objective-C as two methods? I'd like to be able to call the function in Objective-C with or without the default parameter.

[myDerp derp:123];
[myDerp derp:123 derpsalot:456.789];

Is this possible? or do I have to write two separate functions in Swift?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
dave234
  • 4,793
  • 1
  • 14
  • 29

0 Answers0