Post

Replies

Boosts

Views

Activity

Reply to Protocol Not Working
Btw this is all the code related to my protocol and what I am trying to transfer. As for the data on the results print("invoked HockeyDetailVC is", self) gives me invoked HockeyDetailVC is <LearnHockey.HockeyDetailVC: 0x7fe0b3026200>. Can you explain the 0x7fe0b3026200. print("The delegate is nil") gives me The delegate is nil. print("destination HockeyDetailVC is", hockeyDetailVC) This does not print anything to my console.
Jan ’21
Reply to Improve SearchBar
It's not the search string and the array is complete and when parseJson() is run it shows all the cells. When I type E it shows less cells when I type n it shows even less cells, when I type f it shows even less cells but when I delete the f it shows 0 cells and when I delete n it again shows 0 cells so I have to delete everything to restart everything. This function shows the number of cells I have displayed.  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {           print("Number of cells:", cPlayerArr.count)     return cPlayerArr.count        }
Dec ’20
Reply to Improve SearchBar
for my print("search for: ", searchText, searchText.count) it shows the exact amount of characters and the word in the searchbar even when I delete characters. I added the parseJson() right before the filter and it paused it like you said and reset the array. I don't have a textField delegate. This is my cellforItemAt I think thats what you wanted because there is no itemAtRow. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {           let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "colcell", for: indexPath) as! PlayerColCell           let item = cPlayerArr[indexPath.row]     cell.layer.borderColor = UIColor.black.cgColor     cell.layer.borderWidth = 0.5     cell.contentView.backgroundColor = UIColor(red: 102/256, green: 255/256, blue: 255/256, alpha: 0.66)           cell.update(with: item)           return cell        }
Dec ’20
Reply to Improve SearchBar
This is what I have for my class CurrentPlayers. CurrentPlayers {   var photoUrl: String   var position: String   var team: String   var yahooName: String   var birthCity: String   var status: String       init(photoUrl: String, position: String, team: String, yahooName: String, birthCity: String, status: String) {           self.yahooName = yahooName     self.photoUrl = photoUrl     self.position = position     self.team = team     self.birthCity = birthCity     self.status = status         } } My parseJson func performs a get request for an API and it populates the array with JSON data. func parseJson() {     cPlayerArr = []     let url = //url I am using to get data from     var request = URLRequest(url: URL(string: url)!)     request.httpMethod = "GET"           let configuration = URLSessionConfiguration.default     let session = URLSession(configuration: configuration, delegate: nil, delegateQueue: OperationQueue.main)     let task = session.dataTask(with: request) { (data, response, error) in       if (error != nil) {         print("error")       } else {         do {           let fetchedData = try JSONSerialization.jsonObject(with: data!, options: .mutableLeaves) as! NSArray           for eachPlayerNow in fetchedData {             let eachPlayer = eachPlayerNow as! [String: Any]             let player = eachPlayer["YahooName"] as?             String             let position = eachPlayer["Position"] as? String             let photoUrl = eachPlayer["PhotoUrl"] as? String             let team = eachPlayer["Team"] as?             String             let birthCity = eachPlayer["BirthCity"] as? String             let status = eachPlayer["Status"]             as? String             self.cPlayerArr.append(CurrentPlayers.init(photoUrl: photoUrl ?? "", position: position ?? "", team: team ?? "", yahooName: player ?? "", birthCity: birthCity ?? "", status: status ?? ""))           }           self.collections.reloadData().&#9;&#9;&#9;         }         catch {           print("error 2")         }       }     }     task.resume()   }
Dec ’20
Reply to Can't set the slider to 0
Alright I made a func that fixes the issue using the alpha. func goToZero() {     if otSlider.value == 0 {       otShape.alpha = 0     } else if efSlider.value == 0 {       efShape.alpha = 0     } else if ifSlider.value == 0 {       ifShape.alpha = 0     } else {       otShape.alpha = 1       efShape.alpha = 1       ifShape.alpha = 1     }   }
Dec ’20