Reputation: 9705
When I try to do the line below, I dont get a warning (not an error). What is this am I am doing something bad?
I am trying to cast the integer earningsSoFar
to a NSNumber because I want to get the .stringValue
out of it.
I want to understand what is the warning mean here and how to do this right.
self.tv_salaryNumber.text = (earningsSoFar as! NSNumber).stringValue
Upvotes: 5
Views: 10056
Reputation: 24714
You can cast Int
to NSNumber
in this way
let a:Int? = 10
let b = a! as NSNumber
So,in your code,just try
self.tv_salaryNumber.text = (earningsSoFar! as NSNumber).stringValue
Also,as zeneak said,you can make it easier in his way
Upvotes: 7