r/macosprogramming • • Aug 17 '17

Convert NSTextField from String to Double

Hi, I'm trying to convert NSTextField from string to Double whit this: var Strato1: Double? { if let text = Strato1TextField.text { return Double(text) } else { return nil } }

But is not working, someone can Help me?

Thanks in advance

1 Upvotes

2 comments sorted by

View all comments

Show parent comment

1

u/theodinspire Sep 07 '17

The ObjC methods/properties are available in Swift as well. However, a non-number NSString will return zero instead of NaN