UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED - Day 2 Challenge

Forums > 100 Days of SwiftUI

Hi, working on a day 2 solution, I got the basic one down, but trying to make it more interactive

I have this error: No exact matches in call to initializer The line with the error is: let newCelsius = String(celsius)

Here is the entire file

import Cocoa

print("Please enter your tempature you want to convert")
var temp = readLine()

let celsius = temp

let newCelsius = String(celsius)

let fahrenheit = newCelsius * 9 + 32

print("Your tempature in celcius was \(newCelsius))℃ and your fahrenheit tempature is \(fahrenheit)℉")

So I got some help from a friend and managed to get it working like this

import Cocoa

print("Please enter your tempature you want to convert")
var temp = readLine()

let celsius = temp

if let celsius = celsius, let newCelsius = Int(celsius) {
    let fahrenheit = newCelsius * 9 + 32

    print("Your tempature in celcius was \(newCelsius))℃ and your fahrenheit tempature is \(fahrenheit)℉")
}

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.