When doing so I get the Error Code:
Cannot assign value of type '(String, String)' to type 'String?'
As you can see below, I have already converted the Numbers to String values which didn't help.
Ultimately I want to have an UI Label which displays a value + String depending on a switch function.
The Value is going to switch Units and the UI Label should say ( 256 Days or 3.5 hours and for the last example not 0.14 days)
Assigning the Units when printing inti the XCode Console is easy. What I would need is to copy the Console Output ( Target Output) and then paste it into a UI Label, if the other method doesnt work.
Here the Code :
switch Differenz {
case 1...9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 : print (Differenzstring,"Years")
case 0.0027...0.99 : print ( Differenz*365, "Days ")
case 0.000114...0.00269 : print (Differenz * 365*24,"Hours")
case 0.0000019...0.0001139 : print (Differenz * 365 * 24 * 60, "Minutes" )
case 0.000000000001 ... 0.00000189 : print (Differenz * 365 * 24 * 60 * 60,"Seconds")
case 0...0: print ( "Time (almost) stops")
default : print ( "Calculation failed" )
}
// Units not inegrated yet, Result will therefore be in Years perfect would be the Cosnole Output, provided by the Switch Statement also being pasted into "Output Label"
Output.text = String ( Differenz )
}
could you try this out?
var usedTimeLabel = "seconds" //reassign this value when doing switch
Output.text = "\(Differenz) \(usedTimeLabel)"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.