Post

Replies

Boosts

Views

Activity

Trying to display on a collectionview cell.
I'm trying to display different information from an api but all the values are nil. How do I unwrap them?func update(with item: CurrentPlayer) { firstName?.text = item.firstName lastName?.text = item.lastName team?.text = item.team position?.text = item.positionCategory playImg?.image = UIImage(named: "Grey") imageController.fetchItemArtwork(url: item.photoUrl) { (image) in if let image = image { DispatchQueue.main.async { self.playImg?.image = image } } } }
6
0
662
Mar ’20
Transfer From Parent To Child
In my parent I have a function that uses 4 sliders from each child class, and it calculates return on assets. How do I move this method to the child classes so it can update when a slider moves? func calROA() {     let ans = Double(revNum - costNum)/Double(fixANum + curANum)     let perAns = ans * 100     print("this is the value for revenue " + "\(revNum)")     print("this is the value for costs " + "\(costNum)")     print("this is the value for fixed assets " + "\(fixANum)")     print("this is the value for current assets " + "\(curANum)")     print("this is the roa " + "\(perAns)")     roaLabel.text = String(format: "%.1f%%", perAns) }
10
0
519
Sep ’20
Stop Pausing
I use Xcode a lot and recently when I click on something in the storyboard like a label it will pause for some time (little over a minute). my iMac uses 8gb of ram and on activity monitor it shows its using around 6.5gb of ram how can I improve the performance of Xcode so it does not do that?
1
0
266
Sep ’20
Repeat Shrinking An Animation
I am trying to have 2 animations one that increases the label's size and makes it return to its original form but I can't repeat the shrinking like I can increasing the size. How can I shrink it it on loop? func animateLabels() {     UIView.animate(withDuration: 2, delay: 0, options: .repeat, animations: {       //1.5 times it's normal size       self.proLabel.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)     }){ (finished) in       UIView.animate(withDuration: 2, delay: 2, options: .repeat, animations: {         self.proLabel           .transform = CGAffineTransform.identity       })     }   }
6
0
2.8k
Nov ’20
Animations Don't Work On Programmatic Labels
I'm trying to get my animations to work on my labels I have programmatically but when I add them it seems to override my .isuserinteractionenabled. How do I enable these animations? override func viewDidLoad() {     super.viewDidLoad()     proLabel.frame = CGRect(x: 120, y: 840, width: 45, height: 16)     proLabel.text = "profit"     proLabel.textColor = UIColor.black     proLabel.backgroundColor = UIColor.systemBlue     proLabel.font = UIFont(name: "System", size: 15)     proLabel.isUserInteractionEnabled = true     self.content.addSubview(proLabel)           revLabel.frame = CGRect(x: 20, y: 840, width: 65, height: 16)     revLabel.text = "revenue"     revLabel.textColor = UIColor.black     revLabel.backgroundColor = UIColor.systemRed     revLabel.font = UIFont(name: "System", size: 15)     revLabel.isUserInteractionEnabled = true     self.content.addSubview(revLabel)           let tapGestureR = UITapGestureRecognizer(target: self, action: #selector(self.tapRev))     revLabel.addGestureRecognizer(tapGestureR)     let tapGestureP = UITapGestureRecognizer(target: self, action: #selector(self.tapPro))     proLabel.addGestureRecognizer(tapGestureP)     animatePro() //animation added     animateRev() //animation added           buttonNext.layer.cornerRadius = 10         }
1
0
211
Nov ’20
Programmatic Labels Lose Tap With Animations
I don't understand why my animations seem to override my user interaction when I try to tap on a label. What am I missing?   let tapGestureR = UITapGestureRecognizer(target: self, action: #selector(self.tapRev))     revLabel.addGestureRecognizer(tapGestureR)     let tapGestureP = UITapGestureRecognizer(target: self, action: #selector(self.tapPro))     proLabel.addGestureRecognizer(tapGestureP)
2
0
264
Nov ’20