Field Validation and MVVM in SwiftUI

Поділитися
Вставка
  • Опубліковано 3 лют 2025

КОМЕНТАРІ • 38

  • @mhfs61
    @mhfs61 4 роки тому +2

    This wasn’t long at all, because it has value. It is great and clearly explained session. Thanks you for that.

  • @xTwisteDx
    @xTwisteDx 3 роки тому +1

    WOw I'm going to say, I was scared when you said MVVM but it became really clear when you started showing it. Thank you so much!

  • @orchetect7415
    @orchetect7415 4 місяці тому

    11:05 Wrapping regex string literals with hash symbols is a much cleaner and simpler solution than manually dealing with escape characters which can be error-prone when done by hand.

  • @ضدالظلم-د4ح
    @ضدالظلم-د4ح 4 роки тому +2

    You are amazing 😉
    Thank you so much 😊
    I am waiting your videos every day.
    My best wishes for you 👍😍❤️🌹🥰

  • @hueydo3522
    @hueydo3522 4 роки тому

    What a king!!! Sharing valuable knowledge

  • @jonothen2212
    @jonothen2212 2 роки тому

    I like your teaching style Sir
    Lovely

  • @nishadsheikh7148
    @nishadsheikh7148 3 роки тому

    Seriously it's an amazing tutorial.

  • @zcaur7329
    @zcaur7329 4 роки тому

    Such great content. Thank you Stewart !

  • @nmbr73
    @nmbr73 2 роки тому +1

    Only now found this video - yet again very helpful. What I don't get with SwiftUI is, how this can be efficient?!? Take in this example isValidPasswod(): It's called to set the sign-up button's opacity, to set that button's disabled state and to set the text prompt for the password field ... so the exact same RegEx match is performed at least three times. I know it's not much in this example, but in huge applications with complex models these things could stack up pretty quickly, couldn't they?

  • @brucknerdevilliers
    @brucknerdevilliers 2 роки тому

    Spot on.

  • @henryhudson2340
    @henryhudson2340 4 роки тому +1

    MVVM! 😍

  • @EmanNollase
    @EmanNollase 2 роки тому

    This is awesome! Question though, how to validate the fields only when the button is press and add red border to the field not passed the validation? Thanks

  • @AhmedHamad-n7k
    @AhmedHamad-n7k Рік тому

    great job but i have a comment on an issue
    the prompts shouldn’t appear immediately when the user runs the app

    • @StewartLynch
      @StewartLynch  Рік тому

      This is just an example of this screen. You can choose to implement it any way you like.

  • @jarodpaulson9439
    @jarodpaulson9439 3 роки тому

    Hi Stewart, thanks for yet another fantastic video. I downloaded the project and just to experiment I tried removing the @Published wrappers from the String properties in the view model. Obviously, the signUp() method didn't work because the view model was unable to emit the values without the wrapper. It's the console message I started receiving while modifying the text fields I'm curious about and I wonder if you have any insight? "Binding action tried to update multiple times per frame."
    Cheers.

  • @ivanman18
    @ivanman18 3 роки тому

    Great tutorial! What's the github repo of this project? Thanks!

    • @StewartLynch
      @StewartLynch  3 роки тому

      There wasn't one, but there is now:). Link is in the description

    • @ivanman18
      @ivanman18 3 роки тому

      @@StewartLynch Thank you very much! Greatly appreciated!!

  • @candyman3537
    @candyman3537 4 роки тому

    I'm wondering why the isSignupComplete not a @Published variable?

    • @StewartLynch
      @StewartLynch  4 роки тому

      It is a computed property that is the result of the evaluation of 3 published propeties.

  • @evertongrant2814
    @evertongrant2814 4 роки тому

    Awesome session but how is you deleted your @State Private all the same time

    • @StewartLynch
      @StewartLynch  4 роки тому

      Sorry. I don’t understand what you are referring to. Can you give me a time stamp on the video to see what you mean?

    • @runQgC
      @runQgC 4 роки тому

      @@StewartLynch He refers to the part at 12:57 when you adding @Published (or removing @State earlier in the video) in bulk edit for lack of better term. I'm curious about that one too. Thank you

    • @StewartLynch
      @StewartLynch  4 роки тому +1

      ​@@runQgC Oh. I See what is being asked. Xcode has multi-cursor support. You can access multi-cursor mode by holding down the Ctrl & Shift keys and left-clicking in your source file. An additional cursor will appear on screen for each left-click performed. From there, any key you hit will perform that action for every cursor, including highlighting text.

    • @runQgC
      @runQgC 4 роки тому

      @@StewartLynch Thank you Stewart!

  • @RajifarmRopar
    @RajifarmRopar 3 роки тому

    which Tool you use to make videos

  • @craigcurphey5175
    @craigcurphey5175 4 роки тому

    What is a z stack?

    • @StewartLynch
      @StewartLynch  4 роки тому

      A SwiftUI depth stack where views are place on top of each other. You may say zee stack and I may say zed stack.

    • @craigcurphey5175
      @craigcurphey5175 4 роки тому

      Being Canadian, its gotta be a zed stack, lol! So how it it different from your garden variety pushdown stack? Or a horizontal or vertical stack on a storyboard?

    • @StewartLynch
      @StewartLynch  4 роки тому +1

      SwiftUI stacks are different from UIKit stacks. SwiftUI is a declarative ui design architecture so I can't really answer this question in a few words. Here is a web post that might clear things up, www.simpleswiftguide.com/how-to-use-stacks-hstack-vstack-and-zstack-in-swiftui-equivalent-of-uistackview-in-uikit/

    • @craigcurphey5175
      @craigcurphey5175 4 роки тому

      Stewart Lynch aha! Got it. One of these days I will need to spend some time and dive in SwiftUI. Thanks Stewart, and I am getting lots out of your videos especially the ones that are ae not way over my head, lol! The git series was especially useful. Thx again.

    • @StewartLynch
      @StewartLynch  4 роки тому +1

      Hang in there. Also sometimes you have to watch things more than once and then just practice by implementing a concept.

  • @johnjohnes698
    @johnjohnes698 3 роки тому +2

    Amazing video, thank you so much, I REALLY learned a LOT. Allow me to share some knowledge with you, too (I have 10 yrs of programming experience, not with swift though)
    1) it's better to return the boolean result of expression itself, so instead of something like this
    if expression_1 && expression_2 && expression_3 {
    return true
    } else {
    return false
    }
    it's better to do something like this
    return expression_1 && expression_2 && expression_3
    2) with simple constant values returned from a simple boolean expression, instead of this
    if some_bool {
    return "abc"
    else {
    return "xyz"
    }
    you could do this
    return some_bool ? "abc" : "xyz"

    • @StewartLynch
      @StewartLynch  3 роки тому +2

      Yes. Thanks. I use the ternary operator all the time. Thanks for offering an alternative

  • @DizzyFarbanish
    @DizzyFarbanish 2 роки тому

    this isnt proper MVVM, there shouldnt be functions exposing fields in the VM, it should just be observables

    • @StewartLynch
      @StewartLynch  2 роки тому +1

      True. Perhaps mistitled, but it is likely more how devs are developing with SwiftUI than with pure MVVM. Mark Moekens calls the VOODO - View - Observable Objects - Data Objecrts