# String to Double?

**URL:** <https://forums.kodeco.com/t/string-to-double/13288>\
**Category:** Swift\
**Created:** [April 13, 2016, 3:38am UTC](https://forums.kodeco.com/t/string-to-double/13288 "2016-04-13T03:38:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hcri50](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@hcri50](https://forums.kodeco.com/u/hcri50)\
**Post date:** [April 13, 2016, 3:38am UTC](https://forums.kodeco.com/t/string-to-double/13288/1 "2016-04-13T03:38:14Z")

</div>

let testField: String = “2.25”

```
    if let cost = Double(textField.text!) {
        
        print("The user entered a value price of \(cost)")
        
    } else {
        print("Not a valid number: \(textField.text!)")
    }

```

What am I doing wrong?? for I am getting this Error.  
I am not understanding the Error.  
Use of unresolved identifier ‘textField’

---

<div class="post-metadata">

**Author:** ![antonio\_k](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/antonio_k/32/81494_2.png) [@antonio\_k](https://forums.kodeco.com/u/antonio_k)\
**Post date:** [April 13, 2016, 7:48am UTC](https://forums.kodeco.com/t/string-to-double/13288/2 "2016-04-13T07:48:56Z")

</div>

You got an typing error, you properties name is “testField”, you try to convert “textField”  
If you correct your input, you get nevertheless an error, because the value of type String has no member “text”, try first convert the testField String to Double

> let testField: String = “2.25”  
> let testFieldToDouble = (testField as NSString).doubleValue

---

<div class="post-metadata">

**Author:** ![hcri50](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@hcri50](https://forums.kodeco.com/u/hcri50)\
**Post date:** [April 14, 2016, 4:21pm UTC](https://forums.kodeco.com/t/string-to-double/13288/3 "2016-04-14T16:21:35Z")

</div>

Thank you, that is why you do not code very late at night. **THANK YOU.**

---

<div class="post-metadata">

**Author:** ![antonio\_k](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/antonio_k/32/81494_2.png) [@antonio\_k](https://forums.kodeco.com/u/antonio_k)\
**Post date:** [April 14, 2016, 6:21pm UTC](https://forums.kodeco.com/t/string-to-double/13288/4 "2016-04-14T18:21:41Z")

</div>

With pleasure, has also my headaches 🙂
