How to convert label output string to double in swift?
I have a timer that updates the label: labelOutletForSecondsCount.text. The label is initialized with the string "0.00". I, than wanted to keep the stopped timeString (I get from my timer) as Double in a variable, to use it in some calculations.
I thought this line of code should do this, but I get the following "Swift compiler error: I cannot convert the type of the expression" Double "to the type" Double ".
var timeStringIntoDoubleValue = (labelOutletForSecondsCount.text as NSString).doubleValue
He did a great job with this line of code:
var textFieldInsertLengthIntoDoubleValue = (textFieldInsertLength.text as NSString).doubleValue
But why does this not work with labelOutletForSecondsCount.text?
I should mention that I am doing this in computed properties:
var length : Double {
var textFieldInsertLengthIntoDoubleValue = (textFieldInsertLength.text as NSString).doubleValue
return textFieldInsertLengthIntoDoubleValue
}
var time : Double {
var timeStringIntoDoubleValue = (labelOutletForSecondsCount.text as NSString).doubleValue
return timeStringIntoDoubleValue
}
: "" "".