Search code examples
iosswiftxlform

XLFormDescriptor initialize with Title in Swift


Why this works OK:

let formFescriptor = XLFormDescriptor(title: "Sign Up");

And this:

let formFescriptor = XLFormDescriptor(title: NSLocalizedString("Sign Up", comment: nil));

Gives me error:

Cannot invoke initializer for type 'XLFormDescriptor' with an argument list of type '(title: String)'

Why?


Solution

  • NSLocalizedString have non-optional comment, while you are passing nil into it. Change comment to something meaningful in a context, so NSLocalizedString will be initialized properly, as well as XLFormDescriptor.