swift - iOS Learning with Lynda: Getting error can't invoke 'init' with argument of type @lvalue String -


i'm trying follow lynda's (not sure if nonmembers can see it) tutorial on ios 9 , swift, i'm getting error doesn't match screencast. if anyone's familiar, tutorial: "controlling when tapped numbers should not appear in calculator"

this basic calculator i'm trying build. basic idea take number inside label string , convert number , putting string when pressing button "0" won't have multiple zeros on calculator.

func updatetext() {     let labelint:int = int(labelstring)     --> cannot invoke 'init' argument of type '@lvalue string'     label.text = "\(labelint)" } 

in screencast error different:

func updatetext() {     let labelint:int = int(labelstring)     --> value of optional type 'int?' not unwrapped; did mean use '!' or '?'?     label.text = "\(labelint)" } 

edit: screenshot

enter image description here

you need unwrapped labelstring value ! sign, write like,

func updatetext() {     let labelint:int = int(labelstring)!     label.text = "\(labelint)" } 

hope you.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -