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

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -