Swift Structs - Value Type vs. Reference Type

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

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

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

    If you enjoy my teaching/presentation style, I started created courses at seanallen.teachable.com. You can check out the first few videos for free to get a feel for them.

  • @austinkchang
    @austinkchang 4 года назад +36

    The Google Sheets vs. Excel Spreadsheet is such a good analogy!

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

      Thanks Austin 👍

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

    Wow, this is the best video explain the difference of the class and structs I found in RUclips 👏🏻

  • @pratikgupta7373
    @pratikgupta7373 6 месяцев назад +1

    The Google Sheets vs. Excel Spreadsheet is such a good example

    • @seanallen
      @seanallen  6 месяцев назад

      Glad you liked the analogy :)

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

    you teach iOS as simple as apple introduce their new iPhone simple, beautiful and powerful thank you for amazing content and when you start SwiftUI video ?? please start soon

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

      Thanks for the kind words. I'm going to start my shift into SwiftUI content once iOS 14 and Xcode 12 are official in a couple months.

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

      @@seanallen thankyou !

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

    Reaaally clear explanation Sean! Thank you so much! Your analogy was brilliant!

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

      Thanks Fernando. I've used that analogy a lot and many seem to enjoy it.

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

    The analogy is amazing!

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

      Glad you liked it, Tiago!

  • @ssaai
    @ssaai 10 месяцев назад

    what a comparison Google Sheets vs. Excel Spreadsheet 👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻

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

    thanks a lot Sean Allen to explain all this stuck in detail

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

      Glad it was helpful!

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

    I love the analogy!

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

    hello my bro at first of all i want to thank you for all your lecture it's very professional but i want from you publish video about extension keyboard and how it works , there isn't any source for it .
    i hope to make that .
    thanks 🥰

  • @eazy_profit
    @eazy_profit Год назад +1

    Great explanation

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

    perfect explanation thanks

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

    Can you make a video on how to make custom xcode project template in xcode 11

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

    Nice explanation!

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

    Ty Sean!

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

    great vid like always!
    Small polish to your analogy- Classes are more as a blueprints, And by initiating a class you use this blueprint to create an instance (sean in this case). That instance is a reference so if you assign it to any other variable it will lead to the same place in memory (of the instance not the class).
    Honestly its probably a TMI but just wanted to point that out, partially to make sure I understand it correctly.. So basically using this comment as my rubber debug duck :)

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

      You understand it correctly. The blueprint analogy is a good one. I'm going to start using that.

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

      @@seanallen cool :)

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

    not to change the subject but have you checked out The Healthy Software Developer. Great stuff on the Culture. Unique subject matter and the guy is honest and an expert like you.

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

      I've seen their thumbnails pop up in my recommendations, but never watched. I'll check it out.

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

    Sean sir i love your video and skills. i like your style to deliver the information,so much.

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

    this really is an awesome analogy

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

      Glad you liked it, Antonio!

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

    Sean, I always enjoy your videos, they are easy to understand and thorough. One major decision for me when deciding on a Struct or a Class is if I need to use ObservableObjects. If I do then it's a class as Structs don't support it.

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

    Hey Man, Nice Video!
    Can you make a video about Realm, would appreciate it,
    Keep up the good work!

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

      Glad you liked it. I've never used Realm, so it's tough for me to make a video on that one.

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

    The thing that confuses me is that structs can also have methods in it and can implement protocols. Coming from a C background, that is just not making any sense.
    Can you make a video explaining those?

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

      Sanjay Arun C does not have the class keyword but has structs. In C++ there are classes and structs. The only difference between them is that struct members (variables, methods) are public by default where classes are private by default. In languages like C or C++, you have full control over whether you stack or heap allocate and whether you pass something by value or by reference. Other languages like Swift or C# make some things reference types and others value types and handle for you how that gets stored in memory.
      TL;DR
      If you're not familiar with references in C using &variable_name, that may help clear things up.

  • @denisp.7850
    @denisp.7850 4 года назад +1

    Great video as usual! Just one question: why would you need optional properties in a class when you still provide an init? Isn't that the whole point of optionals having no value at the moment of initialization?

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

      If certain properties are optional, then they do not have to be included in the initializer. Making a property optional gives you flexibility in how you initialize your object (you can have more than one initializer per class)

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

    so clear. Thanks!

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

      Glad it was helpful, Hanmok!

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

    Thank You!!

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

    best analogy

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

    so clear.

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

    Hey Sean, great video.
    On an unrelated note, I have a question about React Native. I know you already made a video about it, and you’re an Apple fan boy like myself - but do you think it’ll ever replace Swift development? And with that, do ever plan on learning it? I feel like once you know how to program you can take that skill to any language or framework.
    Thanks Sean,
    Julian

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

      I agree, that once you learn how to program you can pick up a new platform or language relatively quickly (or at least much faster than you learned your first language/platform). I do not believe it will ever replace Swift development and I have no intention on learning it. But that's just my opinion.

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

      @@seanallen Gotcha, thanks for the reply. I've been watching you for a while now and I am really enjoying the content.

  • @Sergey-ue3ro
    @Sergey-ue3ro 2 года назад

    Struct has a memberwise initializer, but classes doesn't have? Why?

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

    what about guard

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

    Someone told me that I had no ‘class.’ I told them, ‘Good. I work better with Structs, anyway.’

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

      Ba dum bum. They're here all week folks. Be sure to tip your waitress. 😀

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

    First!

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

    Hi Sean, your videos are awesome. I think you are the right guy who can help me with this.
    There is a vertical scroll with images I want to display.
    But instead of this being a normal scrollview, I want the feature image to appear larger than the other images. And should the user scroll again a new feature image would appear larger.
    So after each scroll, a featured image would take centre stage. The feature image would also be locked to a certain position and size.
    I understand I might need to use GeometryReader for this? but you can advise.
    Please your help would be greatly appreciated.
    here is a screenshot of something similar, but in vertical, not horizontal.
    www.codeproject.com/KB/scripting/jquery-coverflow/screenshot1.JPG