State Properties in SwiftUI - Lesson 4

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

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

  • @tobiasstil1495
    @tobiasstil1495 4 года назад +22

    The only thing I don't understand is, that your free awesome demonstration of coding has such a small audience 🤔 Keep up the great work, it really helps me!

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

    Thanks for the video, Years ago I thought to do all UI in code with Objective-C. Then as number of views increased I gave in to Storyboards. Now I have come full circle.
    I'll admit your videos make SwiftUI very appealing. I have watched your first 4 old videos here and look forward to watching more. I only started to look at new solutions as I wanted to add WatchKit to my app and they were pushing swiftUI heavily.
    Thanks a ton,
    Art

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

      Thank you so much for the kind words! - Pat

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

    Didn't realize SwiftUI was totally different from the storyboard mode. It definitely looks easier to manipulate after you get the hang of it! Thanks for these videos!

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

    Hey, you are so warm person and your way to explaning and while doing this using your mimics. I feel like I listen my teacher in elementary scool :) Thank you for these tutorials.

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

      Awww, thanks for your kind words, Oguz! We believe in you so much! Glad that we are able to positively impact your learning experience. Keep on going and having fun learning. :-) -Arthur

  • @thomaslenz2202
    @thomaslenz2202 4 года назад +6

    Great Tutorial Series! Keep going. I am new to SwiftUI and Swift iOS development at all, but I am able to build simple apps by now already. Thank you Chris!

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

      That's awesome! Thanks for learning with us!
      Kat

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

    I started do my coursework and I chose the topic "App Development", but actually I've never done the apps ahahaha
    The only things that help me is your tutorials, I absolutely fall in love with it! Thank you so much!!!!

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

      That's awesome! You can do it!
      - Kat

  • @Stan10785
    @Stan10785 4 года назад +4

    Chris
    Great tutorial series. I love SwiftUI and never learned the other.

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

      Thanks! What apps do you want to create in SwiftUI?
      Kat

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

    Your videos are very clear and easy to understand! Thanks!

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

    Thanks a lot Chris, You are the real MVP in this game. for years I tried to start (on and off) programming in X-Code/Swift but I guess now I Do love swiftUI rather than other swift versions. It made all of stuff easier and enjoyable.

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

      Thank you! Glad you enjoyed learning SwiftUI. 🙌
      - Kat

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

    day by day i'm becoming ur fan cris !!

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

    Swiftui is very easy and straight forward

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

      That's true. 👍 Thanks for watching.
      -Kat

  • @bengleeman7105
    @bengleeman7105 4 года назад +6

    Hey, I love the content you make. I just watched your complete series on how to make your first app and was wondering if you have any tutorials that go over what the code would look like if you wanted to click a button to go to another screen. I know it sounds simple but I really want to become a good coder and I think you can really help.

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

      Hello, you can check this tutorial,
      ruclips.net/video/1HN7usMROt8/видео.html
      It''s a bit advanced but you can skim through it and see how to add different screens and how to navigate through them.
      - Francis

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

    Hi Chris! Quick Question: Can you explain why numHearts has to be in a @State rather than a plain variable? Thanks!

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

      Hello, it is a state so it can can "reinitialize" the view or other parts of the app that uses it to update the appearance of what is on the screen, think of it as an "active" variable that fires an event it ever the value changes
      - Francis

  • @ich_16
    @ich_16 4 года назад +4

    really thanks for the challenges ❤️ i am happy that i did finished all of them but with game of thrones Style🌚

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

      Great job on finishing the challenges!!
      -Kat

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

    Very useful tutorial, it helps me lot. You are doing very great work. Thank you.

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

    Very good presentation content and style. Looking forward to SF symbols lesson.

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

    Hi Chris, thank you for the amazing free content!
    I was wondering, is there a way one can declare an element, and then reference to it to modify it. Like the challenge you propose to make the caption style change depending on IsHearted, could I have the Text element defined and then in an if-else modify its attributes? I've tried and even if I have my Text in a @State var, when I call it to modify it it just shows up in the View in double.
    Is there a "solution" to these mini-challenges somewhere? So as not to bother you with basic questions like this one!
    Thank you in advance !

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

      Hello, there might be something wrong in your code a bit because it should not double, maybe the other code runs regarless if its right or wrong so you should check that, easy way is to put a print statement and see how it behaves when you change a state
      - Francis

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

    Chris, i recreated the challenge and it came out to be awesome but in the simulator the screen was plain white, is there a way to fix this?

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

      Hello, sometimes the simulator screen may stay white because your Xcode does not have enough permissions to run, try should also be a button to "refresh" the simulator screen
      - Francis

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

    Hi there, is scrolling a state? Do I need to create 3 states?
    This is my use case...
    Almost like a carousel, my image goes from small to large once in the center of the screen. but then another state is needed for when user clicks on a larger image.
    State 1 - Image is small (before scroll)
    State 2 - Image gets slightly bigger once in center of the phone. (after scroll)
    State 3 - After user taps on the image, it fills the screen as background

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

      Hello, this should be possible by doing a uipageview and adding some scaling to it. but i suggest looking into cocoapods maybe theres a pre-built carousel that you can use
      check out our cocoapods tutorial codewithchris.com/cocoapods/
      - Francis

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

    Thats very usefull, Please take one session on Combine framework. Thanks you

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

      Thank you! Can you send us your requests here please? cwc.to/request
      - Kat

  • @alii.haltameemi3967
    @alii.haltameemi3967 4 года назад +1

    Thanks, very much for your efforts, and I think SwiftUI fantastic, also your presentation is very good

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

      Thanks for the feedback! We really appreciate it.
      Kat

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

    Sir, these videos are great. Thanks for that)) Also, awesome dictation.
    I think, swiftUI is similar to flutterUI, everything is easy and beautiful. Good option to make a awesome UIs

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

      Yes, they say they have similarities. Thanks for watching!
      - Kat

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

    I really enjoyed this video :) Thanks! :)

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

    SwiftUI is awesome

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

    The challenges you gave at the end of this video and the previous video, where can I find the solution of them to cross check, am not able to trace the challenges folder, please help!

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

      Hello, allow our technical support staff to help. Post your concern here: codecrew.codewithchris.com -Arthur

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

    Hi Chris! Your videos are amazing and they're really helping me get a start in app development. I was working on the challenge you gave us, and ran into a strange problem.
    When I put state variables into the parameter lists for all the modifiers for the Text elements, an error pops up for the rendering mode modifying the heart (.original), stating: 'Image.TemplateRenderingMode' is not convertible to 'Image.TemplateRenderingMode?'. Not really understanding that, I just turned .original into a variable and input that for the parameter instead, and the error magically went away. But, in its place appeared "Generic parameter 'Label' could not be inferred", and I have no idea what that means, how to fix it, or why it popped up. Neither error appeared before I started putting variables into the parameter lists for the Text element modifiers. I have tried restarting the program, but the issue persists. Do you have any insight?

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

      Hello, maybe try re-doing the app again instead? it could have had an error while compiling. or you can try clearning the build files first
      - Francis

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

    I completed the challenge, but the image changes size because of the equal spacing. How do I keep the image the same size?

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

      Hello, try looking into the "content compression resistance priority" of the image and make it a higher number
      - Francis

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

    Never mind - I got it!!

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

    hey, just wondering why you used the self. function for manipulating the number of likes but not for filling the heart?

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

      Hello, this was because it was an function/closure inside the "button", and not part of the main body which is why we needed to use the .self to let it know that we are getting the value from the current file and not from inside the "closure" of the button
      - Francis

  • @90jasur
    @90jasur 3 года назад

    So far I am doing as you teach but I add different sembols and effects.... Thank you

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

      Thanks, Jasur! You got this! :-) -Arthur

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

    Can you show the answer to changing the state of the text when heart button is tapped? 🙂

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

    I have not yet played with SwiftUI, this question may be off, however I would have put ```
    Image( systemName: isHearted ? "heart.fill" : "heart" )
    ```

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

    I like SuiftUI, but I like Chris more.😄😄

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

    Swift UI is too nice bro, like I think its super cool and easy... but then again, I haven't been using Storyboards that long so IDK

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

      Yes, I agree, it's super cool and easy. Thanks for watching this. :)
      -Kat

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

    Subscribed! 💕

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

    Somewhat noobie coder - All my code appears to match up (up to 7:06 in the video), but for some reason my toggle doesn't seem to be toggling. I resumed the preview, but when I try to toggle it isn't changing from the filled to empty heart or vice versa. Any thoughts as to why? I've messed with it for a while now and even tried toggling with a switch on a different project and the toggle isn't working in that project either. - Thanks

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

      Hello, are you sure that you @State is declared outside the functions? so that its "global", maybe its just in the wrong place
      - Francis

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

    Hey Chris! I actually have a question. So for my project, I need a back button. I tried using the navigation controller button but I just can't move it. So now I decided to make my own back button but I don't know the code to do it. So can you provide me the code and where to type it and connect my button. GameViewController.swift. or GameScene.swift.

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

      Hello! Could you share your question in our community group here (bit.ly/CodeCrewCommunity)? Just check the posting guidelines (bit.ly/CWCHowToAskForHelp) so we can help you the best as we can! Thanks!
      Kat

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

      @@CodeWithChris Ok

  • @90jasur
    @90jasur 3 года назад

    The challenging part I stuck somewhere. Can you check it please?

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

    awesome
    I love this

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

    I love the declarative style. Hate the implementation. I would like to see properties like in css etc vs the chaining method.

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

      Hello, who knows maybe in a bit of time there will be APIs or frameworks that will let customize the use of external gui like CSS
      - Francis

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

    why did u use..... self.numhearts += 1
    instead of jus numhearts +=1..... it shown an error i saw that but why?

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

      "Hello, this was because it was inside an overload like an inner function or a closure, this will make it outside of the current scope in which we can use ""self"" in order to pertain that we intend to use the current file/class to get the variable and not inside the closure/function
      - Francis"

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

    please do a tutorial about Apple's Combine framework. We are waiting.

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

      Thanks for the suggestion! We'll add it to the list of topics we'll cover. :)
      Kat

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

      @@CodeWithChris Witing..

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

    I don’t get that button option when I add a button the code looks completely different

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

      Hello, it may be because there was changes in the code since it launched.. to be fair this series was made during the initial release of SwiftUI so there have been some changes since then
      - Francis

  • @90jasur
    @90jasur 3 года назад

    I got it !