Swift: Dependency Injection Tutorial (2022) - iOS

  ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 34,316

iOS Academy

iOS Academy

Π”Π΅Π½ΡŒ Ρ‚ΠΎΠΌΡƒ

In this video we take a practical look at dependency injection in Swift by using protocols. Dependency Injection is a powerful pattern to build scalable large applications with decoupled logic. It allows objects to use common functionality in an agnostic way; such that one object does not know where the functionality comes from. We'll be working in Xcode 12 and Swift 5 to demonstrate this with multiple targets.
πŸ’» Source Code: / iosacademy
πŸŽ₯ Subscribe for more: ukposts.info?su...
😎 Like my teaching style? Check out some of my most popular courses! courses.iosacademy.io
** Popular Series
Building Instagram: courses.iosacademy.io/p/build...
Building TikTok: / @iosacademy
SwiftUI for Beginners: ios-academy.teachable.com/p/s...
** Get Skillshare free for 2 Months and learn iOS
www.skillshare.com/r/user/afraz
** Manage all your investments from app earnings on Betterment!
bit.ly/3eBwlI9
** Grow your own UKposts tech channel with TubeBuddy:
www.tubebuddy.com/iosacademy
*Timestamps*
0:00 Swift Dependency Injection
0:49 Create Project
1:50 Create Button
3:24 Create Xcode Target
4:28 Create API Caller
6:17 Create New Target
9:39 Decode API Response
10:40 Create Protocol
13:19 Pass Dependency
18:00 Finalize Data
19:30 Set Up TableView
22:05 Dependency Injection Review
24:14 Wrap Up / Outro
#swift #dependency #iOS

ΠšΠžΠœΠ•ΠΠ’ΠΠ Π†: 70
@awsysumer3814
@awsysumer3814 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Out of million tutorials about DI, this one explains it crystal clear and in a very simple way to understand. Thank you so much. Keep it up πŸ‘πŸ»
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Youre welcome!
@hadyhelal6626
@hadyhelal6626 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Why did you use singleton despite you used dependency injection? i know that one of dependency injection benefit is to remove singleton!!
@jameelshehadeh9011
@jameelshehadeh9011 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
same question here
@TheSpiralnotizblock
@TheSpiralnotizblock 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I was waiting so hard for this! Thank you so much
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
You’re welcome
@laurapotter6321
@laurapotter6321 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thank you for this wonderful tutorial! One question: so the in the dataFetchable protocol, the function needs to have the exact same name with the one inside ApiCaller right ?
@zb1123
@zb1123 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Fantastic video - clear and concise! Cheers!
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Glad it was helpful!
@vinnygen6632
@vinnygen6632 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Been waiting for this! Thanks a lot!
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Hope you enjoyed it!
@barscakmak2867
@barscakmak2867 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@iOSAcademy hey, Do you have learning path for beginner to advance like this topics(di,reactive programming etc)
@BharatKumar-xk6lq
@BharatKumar-xk6lq 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks alot brother πŸ‘ perfect understandable explination πŸ’— loads of love πŸ’—πŸ˜
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
You’re welcome!!
@apoorvas99
@apoorvas99 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Loved it! Thank You so much.
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Youre welcome
@user-zh3el2yr6h
@user-zh3el2yr6h 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Smashing that like button even before watching the video. Thank you!
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
You're the best!
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Enjoy my teaching style? Check out iOS Academy+ at iosacademy.io/plus
@nemotv6623
@nemotv6623 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
DI with MVVM example? Awesome video btw, thanks
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Sure! And thanks!
@ahmetbugraozcan6742
@ahmetbugraozcan6742 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
It was great video but I have different question. What should we do when we require a data to multiple places? I was thinking dependency injection is related to this but it seems it doesnt so I am little confused.
@raychen4458
@raychen4458 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
please can we have another DI tutorials that talks more in depth concepts and how to work with MVVM Much appreciated !!!
@CJWhitaker
@CJWhitaker Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
How do you inject to the home view controller when it's embedded in a Navigation Controller?
@DaveJacobseniOS
@DaveJacobseniOS 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
suuuuper helpful. thanks!
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Youre welcome
@johnmathew2120
@johnmathew2120 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Hi, Thanks for great lesson with easy practical sample. I have one doubt, This injecting will works only on Targets or it will work classes too?
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Youre welcome. Yep it works for both
@johnmathew2120
@johnmathew2120 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@iOSAcademy Thank you πŸ™‚πŸ™‚
@chaitanyakella7937
@chaitanyakella7937 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Beautiful
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks
@cesaralcantara1341
@cesaralcantara1341 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Can you possibly explain the @escaping closures and callback and the reason for this instead of making the function return something? New to iOS development
@novo4249
@novo4249 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Hi Cesar, using callback function to return a value is a common approach to achieve asynchronous function in programming. In this case, the function have to be asynchronous as the network API call is not returning the value immediately. @escaping closure is just the Swift way of implementing callback.
@cesaralcantara1341
@cesaralcantara1341 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@novo4249 thank you so much Hans! I appreciate it!
@tokero5199
@tokero5199 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
This was a very nice tutorial. I know it's slightly off topic but how would you handle dependencies of your separated out targets. Let's say you network module depends on alamofire but you do not want you main app to depend on alamofire.
@ApoCaLypSeXVII
@ApoCaLypSeXVII Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
I mean correct me if I'm wrong but once you import 3rd party dependencies to assist with backend network calls wouldn't it now become a global asset to the whole project? Anything having to do with the API would require you importing in alamofire for each file no?
@RajrkSunny
@RajrkSunny Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
@@ApoCaLypSeXVII I think we can also setup 3rd party for individual targets.
@JP-ks3kh
@JP-ks3kh 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
This is a great tutorial...Thanks a lot! Moarrrr plzzzzz.
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks!
@johncerpa3782
@johncerpa3782 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Excellent
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks!
@phantuananh2163
@phantuananh2163 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
Impressive!!!
@iOSAcademy
@iOSAcademy Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
thanks
@ahopdanzer
@ahopdanzer 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
brilliant di tutorial
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks
@soromiso
@soromiso 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
You're welcome! 😎
@tientranminh9564
@tientranminh9564 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Pls make a tutorial about distribute app over the air
@kalpeshjethva598
@kalpeshjethva598 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
I have multiple environments how can I manage them?
@harivigneshks8817
@harivigneshks8817 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Brother for learning iOS development do we need Mac laptop or any other alternatives and if we want to buy apple laptop what OS needs to be purchased bro
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Yes you need a mac with macos
@harivigneshks8817
@harivigneshks8817 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@iOSAcademy what OS Catalina or bigsur
@harivigneshks8817
@harivigneshks8817 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@iOSAcademy can we do swift programming in virtual machines
@Oisinkelly308
@Oisinkelly308 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Should 256gb be enough for balancing college work and xcode projects or should i invest in 512gb storage? I am going to be purchasing a macbook air soon and don’t know how much storage xcode takes up. Thanks
@maqusss
@maqusss 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
255gb is definitely to small. U need at least 512gb.
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Id invest in 512
@johncerpa3782
@johncerpa3782 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
16 gb of ram, minimum
@Oisinkelly308
@Oisinkelly308 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@johncerpa3782 ordered 512gb ssd 16gb ram
@artikes9519
@artikes9519 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Great Video! Isn't that dependency inversion?
@CastAsHuman
@CastAsHuman 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Exactly my thoughts!
@swiftMyDay
@swiftMyDay 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I broke my iPhone smashing the like button 😩
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Oh no!
@aprishsolanki6584
@aprishsolanki6584 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
I smashed like button with broken phone
@JoeEnos
@JoeEnos 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I’ve only been doing iOS development a few weeks, glad to see I’m not alone with Xcode being really flaky. Visual Studio isn’t perfect, but it seems way more stable and consistent.
@dhikaaditya1920
@dhikaaditya1920 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
kit
@evgenykravtsov2157
@evgenykravtsov2157 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
import UsefullKit
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks!
@sirfetchd9829
@sirfetchd9829 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
this was way too fast
@mumble57558
@mumble57558 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
πŸ‘πŸ‘πŸ‘
@iOSAcademy
@iOSAcademy 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks
MVVM + Dependency Injection in Swift | Unit Testing | iOS
29:29
iCode
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 41 тис.
Factory Design Pattern in Swift & iOS (2023)
10:48
iOS Academy
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 8 тис.
Normal vs Smokers !! 😱😱😱
00:12
Tibo InShape
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 18 ΠΌΠ»Π½
Get a knife! | Standoff 2
01:06
Standoff 2 Live
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 1,5 ΠΌΠ»Π½
Moyens bizarres et cool de faire entrer des bonbons sans se faire prendre
00:40
Mini-mimi
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 27 ΠΌΠ»Π½
Dependency Injection
15:31
SwiftBook
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 14 тис.
Swift API Calls for Beginners (Networking) - Async Await & JSON
25:35
Sean Allen
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 70 тис.
Swinject: Effortless Dependency Injection in iOS (Basics)
12:45
iOS Academy
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 27 тис.
Dependency Injection in 8 minutes (Swift 2023)
9:09
CodeBrah
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 1,6 тис.
How to implement Dependency Injection in Swift!
12:56
Vincent Pradeilles
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 12 тис.
Clean Code in SwiftUI with Open Closed Principle MVVM and Dependency Injection
24:06
Tim Yoon
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 4 тис.
The Most Misused Design Pattern in Swift
5:56
Sean Allen
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 16 тис.
Swift Connection 2023 - Simon B. StΓΈvring. - Achieving Loose Coupling with Pure Dependency Injection
41:23
Tech Connection
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 1,6 тис.
Normal vs Smokers !! 😱😱😱
00:12
Tibo InShape
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 18 ΠΌΠ»Π½