Object IDs: Dependency Injection Fundamentals (iOS) - 2022

  Рет қаралды 4,896

iOS Academy

iOS Academy

2 жыл бұрын

In this video we will learn about object identifiers in swift and Xcode. Object identifiers can be used to form the foundation of dependency injection with resolve and register patterns. We will do some examples in a playground using the latest version of Xcode.
Reference: developer.apple.com/documenta...
💻 Source Code: / iosacademy
🎥 Subscribe for more: kzfaq.info?su...
😎 Like my teaching style? Check out some of my most popular courses! courses.iosacademy.io
👉🏼 Connect (personal LinkedIn) / afrazsiddiqui
🚀 Follow on LinkedIn / ios-academy
** 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 KZfaq tech channel with TubeBuddy:
www.tubebuddy.com/iosacademy
#Swift #DependencyInjection #iOS

Пікірлер: 38
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Lets connect: linkedin.com/in/afrazsiddiqui
@salehmasum9419
@salehmasum9419 Жыл бұрын
Thanks a lot for explaining DI container concept in swift such an easy way. Many Thanks !!
@HisMajesty99
@HisMajesty99 2 жыл бұрын
Always had trouble trying to understand dependency injection, but this video gives me a really good picture, thanks! Definitely looking forward to more on this topic if you ever decide to make them!
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thanks
@User-hg9re
@User-hg9re 2 жыл бұрын
Man you mistaked the second id uses the first object afraz again.
@User-hg9re
@User-hg9re 2 жыл бұрын
And the Ids in the console are the same...
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Yep, I realized this afterwards. Copy and paste got me haha
@User-hg9re
@User-hg9re 2 жыл бұрын
@@iOSAcademy haha, we all do this man, but be more careful next time 😂😀
@User-hg9re
@User-hg9re 2 жыл бұрын
Exfluding that little bug great video!
@TF242
@TF242 2 жыл бұрын
CopyAndPastecidis C is a real disease :)
@fernandocardenasm
@fernandocardenasm 2 жыл бұрын
Hi Afraz, first, I thank you for the great content. I've already watched some videos and I've learned a lot. My question is: isn't this Resolver DI kind of anti-pattern? I mean, you only know whether the resolvers "resolves" into a valid / existing class at run time, so you kind of sacrifice the safety of the compiler warnings. What do you address this? Or what are your thoughts about it? Thanks in advance!
@trappedIRL
@trappedIRL 2 жыл бұрын
Super cool!
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thanks
@aybarsacar9375
@aybarsacar9375 2 жыл бұрын
Great video! You make the best content on iOS on KZfaq. It would be great to see this di container used in an app with full architecture maybe with a similar implementation to dotnet , I would love to see you convert one of the apps you built on here to use dependency injection instead of singletons
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thanks
@alexandergavrilov8019
@alexandergavrilov8019 2 жыл бұрын
wow! thx
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Youre welcome
@leahgagyoungshin736
@leahgagyoungshin736 2 жыл бұрын
Hi! I'm a big fan of your channel Could you please do a video about how to save images to Realm next time? Thank you for your effort all the time and please keep your channel active :)
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Sure thing!
@ho6y
@ho6y 2 жыл бұрын
Why would you try to resolve an instance or metatype in a "real world" app? Maybe to make sure there's only a copy of the same object in some very specific scenario? i'm pretty sure Sets work like that under the hood aswell
@iOSAcademy
@iOSAcademy 2 жыл бұрын
To avoid explicit dependencies
@victorriurean
@victorriurean 2 жыл бұрын
🔥🔥🔥🧨🧨🧨
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thanks
@abdorizak
@abdorizak 2 жыл бұрын
Thanks, bro. I'm struggling to display monthly user data on the chart using the Uikit framework
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Youre welcome
@user-me6wr5nt8z
@user-me6wr5nt8z 2 жыл бұрын
Hah, brain sees what it want to see. You forgot to update instance of a joe for second string, and the addresses were the same.
@fredtruter2713
@fredtruter2713 2 жыл бұрын
Yeah at 2:32 into the video, line 15 should take the ObjectIdentifier(joe) instead of afraz
@cinquain0
@cinquain0 2 жыл бұрын
I would use a simple example that vividly demonstrate the utility of Object Identifiers. All these pieces and code gymnastic just lose the point.
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thanks for the feedback
@triXtyle
@triXtyle 2 жыл бұрын
You know your stuff, but those mistakes are quite annoying, my ADHD brain focuses on the same prints, or the body in the protocol function, and cannot comprehend the important stuff. Type slower, verify your code, and try to make less mistakes.
@cinquain0
@cinquain0 2 жыл бұрын
He danced too much around the main point. We're all human and make mistake.
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thanks for the feedback
@cinquain0
@cinquain0 2 жыл бұрын
Bro the example you gave is too complex. You lost me here
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thanks for the feedback
@ChristopherCricketWallace
@ChristopherCricketWallace 2 жыл бұрын
I may be missing something or maybe you and I use different terms; but I know the "dependency injection" to be something like this: let myService = Service(provider: APIProvider.shared) More specifically it would be a subset of dependency injection called "constructor injection." That is possible because your APIProvider class conforms to your protocol. The Service class depends on any object that conforms to the Providing protocol; so, you inject it via the constructor. I am unclear why you need the resolver. The Resolver's behavior looks more akin to a hash map as a class instance. It's a container for key-value pairs that happen to be objects (of the Providing protocol).
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Correct. Reaolvers aee used in larger apps to pass deps. multiple levels
@oldTiredGuitarist
@oldTiredGuitarist 2 жыл бұрын
You can look at Swinject - it works basically the same as on the video but has some more convenience APIs to easier resolve and register the dependencies. It is no magic. You always need to ask yourself if it is worth to link against another dependency to just do simple cases. Depends on the project I guess
@pascalburlet2046
@pascalburlet2046 2 жыл бұрын
There are different forms of dependency injection. The resolver in the video is one pattern, passing it via init is another. Doing both is what i do (passing the dependency via init, and in the initializer parameter i call the resolvers resolve method and let swift handle all the right type requirements. that way i can test this class isolated with a mock. but still inject dependencies from a higher level to all classes that use it.
How to use Dependency Injection in SwiftUI | Advanced Learning #16
35:32
Swiftful Thinking
Рет қаралды 26 М.
Vivaan  Tanya once again pranked Papa 🤣😇🤣
00:10
seema lamba
Рет қаралды 32 МЛН
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 14 МЛН
Мы никогда не были так напуганы!
00:15
Аришнев
Рет қаралды 6 МЛН
GIST/SURGERY/ MBBS.MS.DNB.NEETPG.NEETSS/ONCOLOGY/DR LALKRISHNA MULWANI TATA
13:06
DR LALKRISHNA MULWANI TATA
Рет қаралды 16
Swinject: Effortless Dependency Injection in iOS (Basics)
12:45
iOS Academy
Рет қаралды 28 М.
Intro to Sendable in Swift 5 (2022)
11:23
iOS Academy
Рет қаралды 12 М.
AsyncStreams Intro in Swift (Concurrency) - 2022
8:53
iOS Academy
Рет қаралды 7 М.
Swift Dependency Injection - What is it? What are the benefits?
6:58
AutoClosures in Swift (Basics) - 2022
6:39
iOS Academy
Рет қаралды 10 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 152 М.
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 252 М.
Debugging in Xcode 13: Tips & Tricks (2022) - iOS
14:02
iOS Academy
Рет қаралды 42 М.
Implementing a simple DI Container in Swift
8:39
iOS Mastery
Рет қаралды 1 М.
Vivaan  Tanya once again pranked Papa 🤣😇🤣
00:10
seema lamba
Рет қаралды 32 МЛН