on-internet
← Community

For Calculator in Swift

Stack Overflow ·

Just gonna warn you, I'm brand new to swift and I'm still getting used to how this works. I've been trying to work on this Calculator project for class. The problem is, I need practice simplifying code. Right now, when a number button is pressed, I have it saved in an array like this. @IBAction func buttonPressed(_ sender: UIButton) { if numBtnPressed == true { numArray.append(sender.title(for: .normal)!) } } so if the button labeled 1 is pressed, it stores ["1"] as a string in the empty array numArray I have a separate structure for operators in case I need it. struct calcFuncs { var add : St

Comments

Sign in or sign up to comment and upvote.

No comments yet.