Responsive Ad Area

Share This Post

test

Xcode Text Field Input Parameter

I created a text field in the storyboard of Xcode, and set the keyboard type to Number Pad, so that the user can only enter numbers into the field. In the view controller, I am trying to set the output from the text field to be a variable in Double type. The output from the text field will always be an Int, Float or Double (because of the Number Pad), but I am having trouble taking the output from the field, and setting it to a Double type variable.

This is what I have been trying to get to work:

@IBOutlet weak var textFieldOutput: UITextField!
var outputInDoubleForm : Double = textFieldOutput.text //This variable must be in Double format

However, the code always gives the error:

Cannot convert value of type 'String?' to specified type 'Double'

Any help is appreciated! Thanks!


Xcode Text Field Input Parameter
Xcode Text Field Input Parameter
test
{$excerpt:n}

Share This Post

Leave a Reply

Your email address will not be Publishedd. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Skip to toolbar