In my app, I'm going into CoreData and grabbing an entry whose type is a Double
, then I'm trying to put that value into a text field in my app.
This looks like
lengthTextField.text = lastSession.length
but I'm getting the error NSNumber is not a subtype of NSString
The value of lastSession.length
is 6.0 for reference. Any suggestions on how to properly put that data in my text field?
Thanks!
In core data numbers are backed by NSNumber
. You can view the documentation here
In swift you can access the string representation of the number through the instance property stringValue
lengthTextField.text = lastSession.length.stringValue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With