Post

Replies

Boosts

Views

Activity

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
Reply to Need Help Transfer Data From Button
I have a custom cell actually. I have the function I used to display it at the bottom. I am curious with willRowAt do I return indexPath?    func update(with itemFav: CurrentPlayers) {     name.text = itemFav.yahooName     team.text = itemFav.team     position.text = itemFav.position     favImg.image = UIImage(named: "Grey")     let url = URL(string: itemFav.photoUrl!)     imageController.fetchItemArtwork(url: url!) {       (image) in       if let image = image {         DispatchQueue.main.async {           self.favImg.image = image           self.favImg.roundedImage()     }    } } }
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to Need Help Transfer Data From Button
Okay I get the same error unrecognized selector sent to instance '0x7fd4c4098200'. I tried both ways but end up with the same error. You don't but the button in the cell? override func prepare(for segue: UIStoryboardSegue, sender: Any?) {       if segue.identifier == "hs" {         if let destinationController = segue.destination as? HighlightsVC, let destName = selectedNameInCell {           destinationController.playerName = destName          }       }     }               override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {     if let cell = tableView.cellForRow(at: indexPath) as? FavCell {       selectedNameInCell = cell.name.text     }     return indexPath   }       @IBAction func CamButtonA(_ sender: UIButton) {     performSegue(withIdentifier: "hs", sender: nil)   }
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to Need Help Transfer Data From Button
Okay I have it working but it goes to the vc twice and it also does not transfer the name. override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {     if let cell = tableView.cellForRow(at: indexPath) as? FavCell {       selectedNameInCell = cell.name.text       print("destName is \(String(describing: selectedNameInCell))") //does not print name     }     return indexPath   }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Need Help Transfer Data From Button
The thing is I don't want the whole cell to be selected. I just want the button to be.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Need Help Transfer Data From Button
I am still confused I don't understand what you mean by cell reference. I am also not sure how to reference the VC inside of UITableViewController.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Need Help Transfer Data From Button
What exactly should I put in my button in my cell that does the action?    @IBAction func CamButtonA(_ sender: UIButton) {     //?    }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Need Help Transfer Data From Button
Oh I forgot to mention that my data source is a set so it is not like that. I'm not sure how to get the value from the cell like you have done. var favSet: Set<CurrentPlayers> {     FavouriteManager.shared.favSet   }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Need Help Transfer Data From Button
Okay I will do that. I have a set because I wanted to avoid duplicates with an array.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Need Help Transfer Data From Button
I have a custom cell actually. I have the function I used to display it at the bottom. I am curious with willRowAt do I return indexPath?    func update(with itemFav: CurrentPlayers) {     name.text = itemFav.yahooName     team.text = itemFav.team     position.text = itemFav.position     favImg.image = UIImage(named: "Grey")     let url = URL(string: itemFav.photoUrl!)     imageController.fetchItemArtwork(url: url!) {       (image) in       if let image = image {         DispatchQueue.main.async {           self.favImg.image = image           self.favImg.roundedImage()     }    } } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Need Help Transfer Data From Button
Okay I get the same error unrecognized selector sent to instance '0x7fd4c4098200'. I tried both ways but end up with the same error. You don't but the button in the cell? override func prepare(for segue: UIStoryboardSegue, sender: Any?) {       if segue.identifier == "hs" {         if let destinationController = segue.destination as? HighlightsVC, let destName = selectedNameInCell {           destinationController.playerName = destName          }       }     }               override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {     if let cell = tableView.cellForRow(at: indexPath) as? FavCell {       selectedNameInCell = cell.name.text     }     return indexPath   }       @IBAction func CamButtonA(_ sender: UIButton) {     performSegue(withIdentifier: "hs", sender: nil)   }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Need Help Transfer Data From Button
The error comes from my camButtonA. Unrecognized selector    @IBAction func CamButtonA(_ sender: UIButton) {     performSegue(withIdentifier: "hs", sender: nil)   }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Need Help Transfer Data From Button
Okay I have it working but it goes to the vc twice and it also does not transfer the name. override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {     if let cell = tableView.cellForRow(at: indexPath) as? FavCell {       selectedNameInCell = cell.name.text       print("destName is \(String(describing: selectedNameInCell))") //does not print name     }     return indexPath   }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Need Help Transfer Data From Button
By twice I mean the VC that I go to calls the API twice. override func viewDidLoad() {     super.viewDidLoad()     fetchYoutubeData {       self.tableView.reloadData()     }    }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21