Post

Replies

Boosts

Views

Activity

Reply to Problem With Filter
OOper says You may be doing something strange beyond my guess where you have not shown yet. Okay I will look at my code again, I will recopy it. Claude31 says Isn't it let defense = NSPredicate(format: "position CONTAINS [D]") I don't think so, I think it's "position CONTAINS 'D'".
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Problem With Filter
Okay I fixed some of my issues, the only issue I now have is the one where multiple cells of the same player are shown when you type in the searchBar. I think it has to do with the updateFilteredArray method below. If we get a specific player we need to basically erase any duplicates. This only happens when selectedScope 0.  func updateFilteredArray(searchText: String) {    let filterArray: [CurrentPlayers]    if searchBar.selectedScopeButtonIndex 0 {      filterArray = filteredArr    } else {      filterArray = cPlayerArr    }    filteredArr = filterArray.filter { player - Bool in      if searchText.isEmpty {        return true      } else { print(filteredArray.count)        return          player.yahooName!.lowercased().contains(searchText.lowercased())      }    }  }
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Problem With Filter
One of the ways I'm trying to remove duplicates by turning it into a set then back into an array when called but that does not seem to work. I could use some more help.    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) - Int {     let noDArr = Array(Set(filteredArr))     if (searchBar.text != "" || searchBar.selectedScopeButtonIndex 0) {       return noDArr.count     } else {       return cPlayerArr.count     }   }
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Need Help Transfer Data From Button
This is the best I could do with making a global variable but what do I put inside exactly willSelectRowAt, You can't put any segues in there. struct GlobalFavPlayer {       func addObserver() {   NotificationCenter.default.post(name: .passFavNotification,                   object: GlobalFavPlayer.globalFav)   }       static var globalFav: CurrentPlayers?         }
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to Need Help Transfer Data From Button
I get the error '-[LearnHockey.FavCell CamButtonA:]: unrecognized selector sent to instance 0x7f9fe6038800'. I created the segue too but I don't know what to put in my willrowat exactly.    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {     if segue.identifier == "hs" {     let destinationController = segue.destination as? HighlightsVC       destinationController!.playerName = GlobalFavPlayer.globalFav!.yahooName!   }   }    override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {     //not sure what to put in here   }
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to Need Help Transfer Data From Button
Okay so I downloaded a swift package that gives me access to an orderedSet so I can solve that issue but thanks for your suggestion. Anyways I get the cannot find cellForRow error in scope.    override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {     if let cell = cellForRow(at: IndexPath) {       selectedNameInCell = cell.yahooName     }   }
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to Need Help Transfer Data From Button
Okay I have a new error this time. Cannot convert value of type 'IndexPath.Type' to expected argument type 'IndexPath' override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {     if let cell = tableView.cellForRow(at: IndexPath) {       selectedNameInCell = cell.yahooName     }   }
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to Need Help Transfer Data From Button
okay thanks but I get the error Value of type 'UITableViewCell' has no member 'yahooName'. I should show my cellForRowAt. I can also access yahooName with currentFav.yahooName but not sure how to access from the cell.    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {     let cell = tableView.dequeueReusableCell(withIdentifier: "favcell", for: indexPath) as! FavCell     let itemFav = favSet[favSet.index(favSet.startIndex, offsetBy: indexPath.row)]     cell.layer.borderColor = UIColor.black.cgColor     cell.layer.borderWidth = 0.5     cell.contentView.backgroundColor = .random     cell.update(with: itemFav)     return cell   }
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21