Dependency Injection In Swift (iOS 2022)

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 มี.ค. 2020
  • Dependency Injection is a powerful tool for any iOS App Developer. We'll walk through examples of injection with Swift 5 and Xcode 11.
    💻 Source Code: / iosacademy
    🎥 Subscribe for more: th-cam.com/users/iOSAcademy?su...
    😎 Like my teaching style? Check out some of my most popular courses! courses.iosacademy.io
    iOS Academy offers the #1 course for iOS Development for Beginners. Learn to create iPhone and iPad apps from scratch. Everyone these days has an app idea; learn the important skill of making those apps, make yourself more marketable, change industries to get a different job, and enjoy the ride!
    This video is brought to you by Skillshare - an only community of teachers sharing awesome skills. Use the following link to get 2 months of FREE premium: www.skillshare.com/r/user/afraz

ความคิดเห็น • 26

  • @fsdolphin
    @fsdolphin 2 ปีที่แล้ว +13

    Very good explanation on protocols but I wouldn't watch the whole video, the zoom-in and out drove me crazy, sorry but I like to see the whole code as much as possible. Thanks.

  • @walktxrn
    @walktxrn 2 ปีที่แล้ว +2

    This isn't Dependency Injection, this is Dependency Inversion. There is a subtle (edit: fixing spelling typo) nuance between the two. This is still well worth knowing and understanding : Source: Me and my PhD Advisor who literally wrote one of the books on the topic ;) if you want to understand the distinction, this is Inversion of Dependencies from the S.O.L.I.D. Principles (the I one). This is 100% worth knowing, but the Poster (and possibly the ios community are conflating different terms), Also Note: Dependency Inversion is also called Inversion of Control (clearer naming)

    • @federicotorres6227
      @federicotorres6227 2 ปีที่แล้ว

      Yes, just a small correction. The 'I' is for "Interface segregation principle", the "D" is for dependency inversion.

  • @agscastaneda
    @agscastaneda 3 ปีที่แล้ว +12

    For those who mention that this is not DI, in Swift, we have two basic types of DI: Initializer Injection and property injection.
    Since Swift is Protocol Oriented Programming (POP!) language you can use protocols as a type, in this video he is using basically Initializer injection.
    And remember one of the goals of DI is to help to create code loosely coupling and he is accomplishing that. IMHO

    • @bobs6473
      @bobs6473 3 ปีที่แล้ว +2

      still this is not get near what di is

    • @abelmengesha3773
      @abelmengesha3773 ปีที่แล้ว

      @@bobs6473 This can only be DI if he was receving the Email, Yahoo and Outlook dependencies from outside. But I see that he's creating those objects within the class. (he's relying on concretion instead of abstraction),

  • @mutasemwahbeh6954
    @mutasemwahbeh6954 3 ปีที่แล้ว +4

    Thank you , in addition It was good to know how to deal with error messages step by step to see what part of code explodes app

    • @iOSAcademy
      @iOSAcademy  3 ปีที่แล้ว +1

      youre welcome!

  • @martinmajewski
    @martinmajewski 2 ปีที่แล้ว +2

    Protocols are like Interfaces in Java, aren't they?

    • @iOSAcademy
      @iOSAcademy  2 ปีที่แล้ว +1

      Yes

    • @martinmajewski
      @martinmajewski 2 ปีที่แล้ว

      @@iOSAcademy I wish there was a mutual convention of how concepts are named. 10 languages, 11 names for the same thing... I learned to call dependency injection "aggregation of objects that implement a common interface"...

  • @swiftlandacademy3193
    @swiftlandacademy3193 4 ปีที่แล้ว

    Really Nice Man... Thanks

    • @iOSAcademy
      @iOSAcademy  4 ปีที่แล้ว +1

      Youre welcome!

  • @sarvarqosimov8363
    @sarvarqosimov8363 9 หลายเดือนก่อน +1

    👍

    • @iOSAcademy
      @iOSAcademy  9 หลายเดือนก่อน

      Thanks

  • @abelmengesha3773
    @abelmengesha3773 ปีที่แล้ว

    I truly appreciate your contents but coming from Android world, this for me is Inversion of Control or the "I" in SOLID principle, here's how Wikipedia defines IoC - "In software engineering, inversion of control (IoC) is a design pattern in which custom-written portions of a computer program receive the flow of control from a generic framework. A software architecture with this design inverts control as compared to traditional procedural programming: in traditional programming, the custom code that expresses the purpose of the program calls into reusable libraries to take care of generic tasks, but with inversion of control, it is the framework that calls into the custom, or task-specific, code."

  • @y3n064
    @y3n064 ปีที่แล้ว

    I think it's not Dependency Injection concept...

  • @VikasKumar-dv7ou
    @VikasKumar-dv7ou 2 ปีที่แล้ว

    This is not DI

  • @hansalucas
    @hansalucas 2 ปีที่แล้ว +2

    zoom gave me a headache

  • @baochenghan4509
    @baochenghan4509 2 ปีที่แล้ว +1

    This is not Dependency Injection!

    • @iOSAcademy
      @iOSAcademy  2 ปีที่แล้ว

      Check out the updated video

  • @byaruhaf
    @byaruhaf 4 ปีที่แล้ว +10

    This is Is polymorphism

    • @followerOfJesus723
      @followerOfJesus723 3 ปีที่แล้ว +3

      No it's not. Protocols ARE not parent classes.

  • @artma5
    @artma5 4 ปีที่แล้ว +3

    Awful presentation. Thx

    • @iOSAcademy
      @iOSAcademy  4 ปีที่แล้ว +2

      Sorry to hear it, Ive got a related follow vid coming soon

    • @swiftlandacademy3193
      @swiftlandacademy3193 4 ปีที่แล้ว +2

      Are you serious?