function - Can't pass nil to two optional parameters -
i'm in process of converting objective-c category swift extension provide simplified methods adding constraints. 1 method equally spacing views has following signature,
func addandequallyspaceviews(views: [uiview], leftortopspace: cgfloat?, rightorbottomspace: cgfloat?, options: nslayoutformatoptions?)
i call this,
self.view.addandequallyspaceviews([view1, view2], leftortopspace: nil, rightorbottomspace: nil, options: .alignallbottom)
i want able pass nil leftortopspace , rightorbottomspace parameters, when pass nil both of them, series of compile time errors. can pass nil either of them alone, not both. why can't pass nil both optional parameters?
the errors i'm getting seem non-specific, , not related line in question,
it's not nil cgfloats. it's implicit enumeration type. here's workaround:
self.view.addandequallyspaceviews([view1, view2], leftortopspace: nil, rightorbottomspace: nil, options: nslayoutformatoptions.alignallbottom)