Calculator App Example Swift Xcode Tutorial

Поделиться
HTML-код
  • Опубликовано: 30 янв 2025
  • ХоббиХобби

Комментарии • 97

  • @Haynxs
    @Haynxs 2 года назад +3

    Great video! I’m building an app revolving around a calculator, now I know it shouldn’t be as expensive as I thought because this is an easy coding process lol.

  • @ceciliaw1065
    @ceciliaw1065 Год назад

    Thank you Cal!!!! Just wanted to say I really appreciate the succinct and straight-to-the-point style you have, as someone with the attention span of a gold fish, I respond to short videos so much better, honestly learned more from this 10-min video than long lectures

  • @alexsal6069
    @alexsal6069 Год назад

    Thank you so much for this video, it helped me a lot to start making interfaces using Storyboards 🤓

  • @josuecruz0921
    @josuecruz0921 3 года назад +2

    Great tutorial !! Truly appreciate it 🙏🏽

  • @johnwane7756
    @johnwane7756 3 года назад +2

    Awesome Video!!!!!!!!! I had to put the speed of the video on 0.5 to follow, but great stuff man. Thanks!!!! Got a new subscriber 😉

    • @CodeWithCal
      @CodeWithCal  3 года назад

      Thanks, Glad you liked it :)

    • @KseniyaKhakimova
      @KseniyaKhakimova Год назад

      Я тоже смотрела на скорости 0,5 😅😅

    • @johnwane7756
      @johnwane7756 Год назад

      @@KseniyaKhakimova 😂😂😂

  • @Arcanegon
    @Arcanegon 9 месяцев назад

    Thank you for the video, this has been a nice experience! A quick question, who did you write the backspace character as an icon? I have been trying to do that but wasn't able to achieve it.

  • @rajrawat3628
    @rajrawat3628 3 года назад +4

    just asking can you please reply to this comment with that backspace x icon that you used in your video for the x button

  • @5.0Matthew
    @5.0Matthew 3 года назад +2

    How did you add the back tap button on the calculator?

    • @CodeWithCal
      @CodeWithCal  3 года назад +1

      Copy pasted the character from the internet. :)

    • @5.0Matthew
      @5.0Matthew 3 года назад

      @@CodeWithCal Thank You

  • @agniya3204
    @agniya3204 3 месяца назад

    hii I have a question,how to make it impossible to divide by zero ?

  • @jdemon3529
    @jdemon3529 2 года назад

    Hey I have a question so when i put 1 / 2 for example instead of returning 0.5 it always returns 0 anything would help :)

  • @xbrcerk
    @xbrcerk 4 месяца назад

    Nice video thank u. My question is 6/4 = 1 u should write 6/4.0 for correct answer 1.5

  • @kuzmakulishin
    @kuzmakulishin 4 года назад +3

    thank you so much for the video!! How can I add a 3-character split? When I enter 10000000 and the screen shows 10 000 000, or 1000 -> 1 000?

    • @CodeWithCal
      @CodeWithCal  4 года назад +2

      try putting this outside of view controller class
      extension Double
      {
      func round(to places: Int) -> Double
      {
      let divisor = pow(10.0, Double(places))
      return (self * divisor).rounded() / divisor
      }
      }
      extension Formatter
      {
      static let withSeparator: NumberFormatter =
      {
      let formatter = NumberFormatter()
      formatter.numberStyle = .decimal
      formatter.groupingSeparator = " "
      return formatter
      }()
      }
      extension Numeric
      {
      var formattedWithSeparator: String { Formatter.withSeparator.string(for: self) ?? "" }
      }

    • @CodeWithCal
      @CodeWithCal  4 года назад +2

      Now using the extensions in previous comment, our format result can look something like this:
      func formatResult(result: Double) -> String
      {
      var roundedResult: Double
      if(result.truncatingRemainder(dividingBy: 1) == 0)
      {
      roundedResult = result.round(to: 0) //return String(format: "%.0f", result)
      }
      else
      {
      roundedResult = result.round(to: 2) //return String(format: "%.2f", result)
      }
      return roundedResult.formattedWithSeparator
      }

    • @kuzmakulishin
      @kuzmakulishin 4 года назад

      @@CodeWithCal Super! It's working! But I want the 3-character split to be displayed also when I enter the calculation. For example 1_000+2_000 ...

    • @Master-lo5df
      @Master-lo5df 2 года назад +1

      Simply use a for loop with a counter.

  • @ritwiksaini4190
    @ritwiksaini4190 3 года назад

    hey, can someone help me with the documentation of this program using markdown?

  • @chikuzone
    @chikuzone 2 года назад

    Thank you so much
    Very good tutorial.. Very helpful for me... Thanks a lot❤

  • @RAJSINGH-uv5xu
    @RAJSINGH-uv5xu 3 года назад

    amazinnngggggggggggggg its blow my mind
    u created in just 10 min i was struglling from 3 hour,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,respect
    🌐

  • @pavelegorov6872
    @pavelegorov6872 9 месяцев назад

    After starting the application and rotating the screen, all Constraints are removed and turn to mush.

  • @mahmutbayulgen6357
    @mahmutbayulgen6357 2 года назад +1

    First, thanks for the demonstration. Very helpful video for the tutorial. Maybe I mistaken somewhere but divide operator resulting with integer and not giving the exact result. For ex. 15/2=7

    • @navedkhan6643
      @navedkhan6643 Год назад +2

      workings = workings.replacingOccurrences(of: "/", with: "*1.0/")
      let checkedWorkingsForPercent = workings.replacingOccurrences(of: "%", with: "*0.01")
      let expression = NSExpression(format: checkedWorkingsForPercent)
      let result = expression.expressionValue(with: nil, context: nil) as! Double
      let resultString = formatResult(result: result)
      calculatorResults.text = resultString

    • @NK-sj4wk
      @NK-sj4wk Год назад

      @@navedkhan6643 thank you!

  • @josuecruz0921
    @josuecruz0921 3 года назад +1

    I've been learning iOS development for a few months now and it's going well. What's the best way to start learning and memorizing all these available types' properties and methods? Thanks in advance.

    • @CodeWithCal
      @CodeWithCal  3 года назад +6

      My advice would be not to try and memorize anything really. Good developers know what's possible and how to find out how to do it when the time comes.
      There will be things that you do so often the you do memorize it. But that happens naturally in my experience.
      Good luck with the iOS development.

  • @battypompano7050
    @battypompano7050 2 года назад

    Why does it crash when I just punch in equals?

  • @MNSB1
    @MNSB1 4 года назад +2

    Hey Cal, just a quick question. When I try to change the background colour of my stack view, nothing happens. Is there a reason and how can I fix this?

    • @CodeWithCal
      @CodeWithCal  4 года назад

      Hi, could be a couple of different things. Background color changing should generally just work though, never the less here a few things to check.
      1- double check you are indeed changing the right stack views background color via the attributes inspector.
      2 - make sure there is nothing in the story board overlaying and covering your stack view.
      3 - Stack view has some position constraints so its not lost to the side or too small to see.
      Hope this helps.

    • @MNSB1
      @MNSB1 4 года назад

      @@CodeWithCal it seems as though it is still not working. I have checked it a million times and I have no idea.

    • @CodeWithCal
      @CodeWithCal  4 года назад

      @@MNSB1 If you would like to. No pressure.
      Using quick time you can record your screen. Make a quick recording and email me at calsappdev@gmail.com I'll have a look :)

    • @MNSB1
      @MNSB1 4 года назад

      @@CodeWithCal I wasn’t able to send a screen recording but I was able to record and send it on my phone

    • @marijam.6172
      @marijam.6172 Год назад

      @@MNSB1 Hey! Did you ever manage to fix this? I encountered the same problem and can't seem to fix it :)

  • @PhuongTrends
    @PhuongTrends 4 года назад +2

    thank you very much :D

  • @balayyababuladyfans1824
    @balayyababuladyfans1824 2 года назад

    Excellent code simply awesome

  • @WajihaKanwalWJK
    @WajihaKanwalWJK Год назад

    You squeezed 1 hr tutorial in 10 mins :). Anyways, good for a quick start. As to check for the validity of an expression, I would rather stop a user at entry point and would not let him add operators together

  • @farukince8308
    @farukince8308 2 года назад

    Hi, cal. I have some problems. The 5, 8, 6, and dot buttons do not work. That's why the code in the appDelegate part gives an error. But the other buttons work. I don't know how to solve this problem.

  • @deanwthompson5633
    @deanwthompson5633 4 года назад

    Love the tutorials!

    • @CodeWithCal
      @CodeWithCal  4 года назад +1

      Thanks :)

    • @deanwthompson5633
      @deanwthompson5633 4 года назад

      @@CodeWithCal
      func formatResult(result: Double) -> String {
      if(result.truncatingRemainder(dividingBy: 1) == 0) {
      return String(format: "%.0f", result)
      } else {
      return String(format: "%.2f", result)
      }
      }
      how could one edit this so that when I divide, for example, 5 and 7 it will spit out 0.71? Any help would be much appreciated

    • @CodeWithCal
      @CodeWithCal  4 года назад +1

      That is what's happening correct?
      We are saying if the result is a full number print 1 for example
      And if there is a decimal print 1.17 etc.
      5/7 the formatted result should be 0.71 :)

    • @deanwthompson5633
      @deanwthompson5633 4 года назад +1

      @@CodeWithCal still not working. I must have an error somewhere else in my code. I will double check your source code! Thanks for the speedy reply!

  • @kaedehara3312
    @kaedehara3312 3 года назад

    Can you do a setting in a calculator that can change the background, font of text, and the background color.

    • @CodeWithCal
      @CodeWithCal  3 года назад

      Absolutely.
      Check out this video I made regarding user defaults. You could add a settings page to allow the user to choose the theme.
      ruclips.net/video/Hf_sianDJWY/видео.html

  • @unpreeable
    @unpreeable 11 месяцев назад

    man i just want a similar calculator app for ios

  • @knee7468
    @knee7468 Год назад +4

    super low quality tutorial, i barely have experience with xcode, and this tutorial didn't help much to understand more of the program.

  • @2tan13y6
    @2tan13y6 3 года назад

    Can u pls help me when I press = without any input the app will crash

    • @CodeWithCal
      @CodeWithCal  3 года назад

      What does your error message say?
      Check the validInput() function. that should be checking well to see if there is valid input :)

    • @2tan13y6
      @2tan13y6 3 года назад

      @@CodeWithCal it says "unable to parse the format string \" ==1\""

    • @CodeWithCal
      @CodeWithCal  3 года назад

      Hmm 🤔 so it's probably not liking two equals signs next to each other. try looping through the string to check if two equals signs are next to each other.

  • @ВимВом-ф6ы
    @ВимВом-ф6ы 2 года назад

    thanks

  • @keshavrawat6575
    @keshavrawat6575 3 года назад

    when I run my app in the simulator it shows me a white screen, why?
    and please help me

    • @CodeWithCal
      @CodeWithCal  3 года назад

      hmm could be a number of reasons. But most likely something has gone wrong with the set up of your storyboard. Any more details you can provide?

    • @keshavrawat6575
      @keshavrawat6575 3 года назад

      ​@@CodeWithCal If you have a email I can send images of the error

    • @CodeWithCal
      @CodeWithCal  3 года назад

      @@keshavrawat6575 calsappdev@gmail.com

  • @salmanmaskati525
    @salmanmaskati525 3 года назад

    i love it , nice work , i but i tried to do it but i got many errors :D

  • @amitarya4894
    @amitarya4894 Год назад

    what is this "%" character doing here is not clear.

  • @narraxis
    @narraxis Год назад

    Couldn't you just create a single IBAction for a button and make it read values from text? That would be so much easier and less code, at least for numbers

    • @CodeWithCal
      @CodeWithCal  Год назад

      You could absolutely. Lots of ways to skin the cat as they say

  • @mohdayaan5362
    @mohdayaan5362 2 года назад

    Threat 1: fatal error: UNEXPECTED FOUND NIL WHILE IMPLICITLY INWRAPPING AN OPTIONAL VALUE…….. this error is coming while running the program…
    Plz help

    • @CodeWithCal
      @CodeWithCal  2 года назад

      UNEXPECTED FOUND NIL WHILE IMPLICITLY INWRAPPING AN OPTIONAL VALUE
      The error message says it all 😜

  • @Dearpest
    @Dearpest 2 года назад

    hey guy why are you do speedrun

    • @CodeWithCal
      @CodeWithCal  2 года назад

      Yeah I can get carried away with speed 🚅

  • @dawoodabuzahra5336
    @dawoodabuzahra5336 4 года назад +1

    can I contact with you??

    • @CodeWithCal
      @CodeWithCal  4 года назад

      Sure thing.
      calsappdev@gmail.com

  • @chiltoncharles
    @chiltoncharles 4 года назад

    you are CAL EL

  • @HFYBook
    @HFYBook 3 года назад

    Hey can you help me out please?

    • @CodeWithCal
      @CodeWithCal  3 года назад

      Hey sure thing. what's up?

    • @HFYBook
      @HFYBook 3 года назад

      @@CodeWithCal Thread 1: "[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key calculatorworkings."

    • @HFYBook
      @HFYBook 3 года назад

      I kept getting this error

    • @CodeWithCal
      @CodeWithCal  3 года назад

      @@HFYBook stackoverflow.com/questions/3088059/xcode-how-to-fix-nsunknownkeyexception-reason-this-class-is-not-key-valu
      Looks like there could be a bad connection in your xib this stack overflow article explains well I believe :)

    • @HFYBook
      @HFYBook 3 года назад +1

      @@CodeWithCal thank you!

  • @rout.network
    @rout.network Год назад +1

    lol slow down.

  • @udaranayana8305
    @udaranayana8305 2 года назад

    bro what's the rush? the tutorial is too fast. this is not good for beginners. Im trying to get my hands on xcode to try out my first mobile app and all im seeing is u clicking here and there like a maniac

    • @CodeWithCal
      @CodeWithCal  2 года назад +1

      Point taken, I can go a little fast. Some people like the pace some people don't haha. Good luck, hope you enjoy your programming journey.

    • @udaranayana8305
      @udaranayana8305 2 года назад

      @@CodeWithCal nevertheless i still managed to complete your tutorial. it was enjoyable. but hope it was bit slower.

  • @k4_yne
    @k4_yne 3 года назад

    you talk too fast...

    • @CodeWithCal
      @CodeWithCal  3 года назад

      Yeah I got a bit carried away, Thanks for the feedback.

    • @urwa6142
      @urwa6142 3 года назад +1

      @@CodeWithCal not too fast

  • @mariolalicata4963
    @mariolalicata4963 3 года назад

    WORTHLESS !!!

    • @CodeWithCal
      @CodeWithCal  3 года назад +1

      Strong words. I'm open to constructive criticism. What didn't you like about the tutorial?

  • @sanjugaikar5408
    @sanjugaikar5408 Год назад

    Ik having answer 0 every time🥲