In my view controller:
class FoodAddViewController: UIViewController, UIPickerViewDataSource, UITextFieldDelegate, UIPickerViewDelegate {
let TAG = \"FoodAd
You cannot use instance variables in function declarations. Call the function with your textFields array and pass the parameters.
func validateAllTextFields(textFields: [UITextField] ) -> Bool {
var result = true
for textField in textFields {
result = validateTextField(textField) && result
}
return result
}
somehwere in your class:
validateAllTextFields(textFields: [foodName, foodPortion, foodCalories])
Or you check inside of your function if textFields is empty and than u use the instance variables
func validateAllTextFields(textFields: [UITextField] ) -> Bool {
if textFields.count == 0 {
textFields = [foodName, foodPortion, foodCalories]
}
var result = true
for textField in textFields {
result = validateTextField(textField) && result
}
return result
}