r/iOSProgramming • u/shubham_iosdev • Jun 22 '22
Application Animated Calculator created using the SwiftUI framework
13
15
u/rotato Jun 22 '22
This is cool. Was the calculator algorithm itself more difficult to program than the entire UI?
21
u/syth9 Jun 22 '22 edited Jun 22 '22
Swift (and essentially all languages) have all the operational rules for arithmetic baked into to the language. For Swift you can just use NSExpression to evaluate the equation input string. No need to write an algorithm. (Example: https://stackoverflow.com/questions/24704028/nsexpression-calculator-in-swift)
The main thing that would need to be handled on the math logic side would be presenting arithmetic errors in a human-readable way that’s fits the UI (like divide by zero) and (if desired) supporting multi-step calculations when a user wants to use the previous results with the next equation
4
u/skviki Jun 22 '22
Great! Another random question: Where did you get the things (sort of organizer, don’t know the word) on the wall?
2
u/shubham_iosdev Jun 23 '22
Thanks :D
I got it from IKEA, it's called Skädis Pegboard.
1
u/skviki Jun 23 '22
Thanks! I missed they have that, I wanted someone to male me something like that by order. Will check if it fits under the cupboards and desk
4
4
u/KarlJay001 Jun 22 '22
Looks great, are you going to post the code?
IDK if Stanford 193 has done the calc in SwiftUI yet or not.
I wouldn't mind a calculator that has the ability to list prior input, kinda like a paper tape history.
It would also be cool to go back and correct entries. I know, it's getting close to being a spread sheet instead of a simple calc :D
2
u/shubham_iosdev Jun 23 '22
Thanks!
Yeah, I'll do it soon after implementing your suggestion. I myself had scenarios in which I wish I could go back to modify some values instead of having to input all of them again. :D
3
u/joshdude09 Jun 22 '22
Very cool! Random question, what keyboard is this?
4
6
u/Evgeny_19 Jun 22 '22
Looks like Logitech MX Keys. Or perhaps its subvariant: Logitech MX Keys for Mac. The later doesn't have any Windows keys on it, and it does have a right Ctrl and an eject key. Otherwise they are very similar. Both are very nice keyboards with backlighting and usb-c. The key travel, however, is noticeably bigger than on Apple's Magic keyboards.
0
4
2
7
u/lilnuggieee Jun 22 '22
Super cool. It’d be awesome to watch a tutorial for this