Posts

Post marked as solved
2 Replies
438 Views
I have 3 UIButtons, and 3 different variables:     var firstSign: Sign?     var secondSign: Sign?     var thirdSign: Sign? My goal is to set Title for each button with each variable in random order. I did it for first one and second one, but can't figure out how to add third title. The second one goes as title for Button 2 & 3. This is Quiz game app so first button is additionally marked as rightAnswer.         rightAnswerPlace = arc4random_uniform(3)+1         var button: UIButton = UIButton()         for i in 1...3 {             button = view.viewWithTag(i) as! UIButton             if (i == Int(rightAnswerPlace)) {                 button.setTitle(firstSign!.name, for: .normal)             } else {                 button.setTitle(secondSign!.name, for: .normal)             }         } I know the code above is not completed, but I can't figure out how to add thirdSign variable into the for loop as third button title.
Posted
by krzychug.
Last updated
.
Post not yet marked as solved
9 Replies
750 Views
Hello all, Im working on my project and stuck at point of searching through the tableView. I can't figure out how to change my code to filter position in my Categories (name and code). At this moment Search bar filters only Categories name, without category content. Array: var categories: [Category] = [         Category(name: "Name", sign: [Sign(code: "code", name: "name", description: "description", picture: "picture"), My searchbar func which filter only categories ([Category]) func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {         filteredCategories = []         if searchText == "" {             filteredCategories = categories         } else {             for signs in categories {     if signs.name.lowercased().contains(searchText.lowercased()) {                     filteredCategories.append(signs)                 }             }         }         self.tableView.reloadData()     } Thanks for your advices
Posted
by krzychug.
Last updated
.