Swift Unwrapping Optional double [on hold]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

Swift Unwrapping Optional double [on hold]



I am getting an optional in type double after building. I have attempted the if let to no avail, I might be writing it wrong.


if let



enter image description here



How do I safely unwrap this?



In Meal.swift



Using SwiftyJSON.


var price: Double?

init(json: JSON)

price = json["price"].double




In MealCell.swift


priceLabel.text = "Php (meal.price)"



Attempted if let:


if let


if let price = meal.price
priceLabel.text = "Php (meal.price)"



This line contains warning:
String interpolation produces a debug description for an optional value; did you mean to make this explicit?



Could anyone help me work out what I need to do?



This question appears to be off-topic. The users who voted to close gave this specific reason:





“I have attempted the if let to no avail, I might be writing it wrong.” we can only find out if you show us what you tried.
– Fogmeister
2 days ago





I've edited it for the attempt.
– Cons Bulaquena
2 days ago





@ConsBulaquena in your code... you create a variable called price... and then ignore it. Use the variable you created.
– Fogmeister
2 days ago




1 Answer
1



You can try


if let price = meal.price
priceLabel.text = "Php (price)" // <<<<<<< (price) not (meal.price)

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Mass disable jenkins jobs