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,

enter image description here

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) 

Popular posts from this blog

javascript - Js, document.getElementById("ID").innerHTML, error -

jquery - jqGrid update specific column data with out refreshing the entire column? -

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -