1

I have some problems with this error,I'm a beginner I will be very happy if you help me I try more variants but it didn't work

var x:Double = 0 


@IBAction func digitals(sender: UIButton)
{

    println("Cifra\(sender.tag)")
    if enterFlag == 1 {

        x = 0
        enterFlag = 0
    }


    if decimalPoint == 0
    {
        x = x * 10 + Double(sender.tag)

        self.result.text = " " + String(Int64(x))
    }
    else {
        x = x + Double(sender.tag)/pow(10, Double(power))
        power++
        self.result.text = String(x)  ===> error

    }


}

thank you very much for your advice ! :)

2 Answers 2

2

There is no intializer to convert Double to String but You can convert Double to String by

self.result.text = "\(x)" 

You can use this way to convert any basic datatype to String

0
0

You can not convert a Double to a String.

You could use:

self.result.text = NSString(format: "%.2f", x)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.