I am getting ingredients, preparings values from response and I want this text to be rendered with breaks, dashes and pointers when displayed on screen. How can I achievie this?
if let ingredients = dict["ingredients"] as? Array<String> {
self._ingredients = ingredients.joined(separator: " \n - ")
This works, however not for the first element in array.
4 elements
- 0 : "3 glasses of flour"
- 1 : "1 spoon of salt"
- 2 : "spices"
- 3 : "1 glass of hot water"
I want this to look on ViewController's label, like this:
- 3 glasses of flour
- 1 spoon of salt
- spices
- 1 glass of hot water
For preparing I want to add appropriate number pointer:
if let preparing = dict["preparing"] as? Array<String> {
self._preparing = preparing.joined(separator: "\n")
3 elements
- 0 : "Mix dry ingredients."
- 1 : "Add hot water, oil, sugar to yeast."
- 2 : "When it's ready add this to flour and start combining"
So it looks like this in label:
1. Mix dry ingredients
2. Add hot water, oil and sugar to yeast
3. When it's ready add this to flour and start combining
Additional info Screen of how it look's currently (don't mind language, it's in polish).
And on this Controller's lifecycle I do simple updateUI
func updateUI () {
pizzaDesc.text = pizza.description
ingredientsDesc.text = pizza.ingredients
PreparingDesc.text = pizza.preparings
titleLbl.text = pizza.title
}
//MARK: Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
hideTestDataOnLoad()
pizza = PizzaRecipe()
pizza.downloadRecipeDetails {
self.updateUI()
}
}