У меня есть сегмент управления, чтобы определить уровень сложности для приготовления рецепта. Мне нужно загрузить значение, назначенное по одному рецепту, чтобы не редактировать его. Следующий код:
@IBOutlet var segNewDifficultyLevel: UISegmentedControl!
@IBOutlet var ingredientTableView: UITableView!
@IBOutlet var directionTableView: UITableView!
weak var delegate: AddNewRecipeViewControllerDelegate?
// MARK: - Variabili Globali
var editRecipe: RecipeModel!
var difficultyLevel: String!
var ingredients: [IngredientModel] = []
var directions: [DirectionModel] = []
Этот код находится в viewDidLoad:
if let editToRecipe = editRecipe {
title = "Edit Recipe"
// Load data from Recipe Detail into editRecipe
viewImageNewRecipe.image = editToRecipe.imageRecipe
fieldNewRecipeName.text = editToRecipe.nameRecipe
fieldNewQuantityFor.text = editToRecipe.quantityRecipe
fieldNewPrepareTime.text = editToRecipe.preparationTime
fieldNewCookingTime.text = editToRecipe.cookingTime
fieldNewBakingTemp.text = editToRecipe.bakingTempRecipe
/* Load the Difficulty Level selected in the recipe */
segNewDifficultyLevel.selectedSegmentIndex = ???
Кто-нибудь может мне помочь, пожалуйста?
Огромное спасибо !!!
Модель Класс рецепта:
class RecipeModel: NSObject, NSCoding
{
var nameRecipe: String
var quantityRecipe: String
var recipeTime: String
var preparationTime: String
var cookingTime: String
var bakingTempRecipe: String
var difficultyLevelRecipe: String
var imageRecipe: UIImage
var ingredients: [IngredientModel]
var directions: [DirectionModel]
var recipeTimeInt: Int
{
var sumRecipeTime: Int = Int(recipeTime)!
sumRecipeTime = Int(preparationTime)! + Int(cookingTime)!
return sumRecipeTime
}
init(nameRecipe: String, quantityRecipe: String, recipeTime: String, preparationTime: String, cookingTime: String, bakingTempRecipe: String, difficultyLevelRecipe: String, imageRecipe: UIImage, ingredients: [IngredientModel], directions: [DirectionModel]) {
self.nameRecipe = nameRecipe
self.quantityRecipe = quantityRecipe
self.recipeTime = recipeTime
self.preparationTime = preparationTime
self.cookingTime = cookingTime
self.bakingTempRecipe = bakingTempRecipe
self.difficultyLevelRecipe = difficultyLevelRecipe
self.imageRecipe = imageRecipe
self.ingredients = ingredients
self.directions = directions
}
...
}