ios - Swift 2.0 'unexpected trailing closure' error with lazy var assignment -
i'm converting project swift 2.0 , keep coming across error everywhere i'm using lazy var. code works in 1.2 breaks in 2.0:
lazy private var placeholderimage = uiimage(named: "theimage")
but, code generates 'unexpected trailing closure' error in 2.0.
following xcode's suggestions fix error, come out with:
lazy private var placeholderimage: uiimage = uiimage(named: "theimage")!
this compiles , seems work, don't understand why change necessary in first place.
in apple developer forum apple staff (chrislattner) said:
yep, known bug (and reported) type inference isn't working lazy properties. adding explicit type annotation best way work around now.
the issue discussed in this google group
Comments
Post a Comment