I'm going to say it here once more: do not use this trick in your production code 🙅🏻♂️ It's more than likely to get you into big troubles at one point or another ⚠️
@HumbleHustle101 Жыл бұрын
This technique can be super helpful in testing the private properties in the unit tests. Thanks for the nice video.
@donathmm38813 жыл бұрын
Thank you. It Would be better if you could've shown us what this first child prints in the end
@rahuljamba5846 Жыл бұрын
Great and excellent, Thanks for sharing your knowledge ❣❣❣
@HumbleHustle101 Жыл бұрын
Nice video, is there any way that we can declare private types in protocols?
@happycamperjack3 жыл бұрын
Hmmm…. looking at the mirror for “private” stuffs. I wonder how Vincent got this idea from 🤔
@ArieP203 жыл бұрын
Very well explained and a very cool technique using Mirror but in case of unit tests, couldn’t you have marked service as internal instead of private? Is it good practice to mark internal? I think I read something about it on Apple’s documentation.
@mykytakhlamov Жыл бұрын
great topic, thanks
@sanadbarjawi56463 жыл бұрын
Very good explanation!!
@konstantinosnikoloutsos34023 жыл бұрын
This is good but can we make it one step further and instead of string use something that will compile time check if property exists? Because if someone change his private class fields then we will only detect it at runtime. Can keypaths help us with this?
@v_pradeilles3 жыл бұрын
Unfortunately the runtime aspect is an inherent part of the technique, I’m not aware of anyway to go around it 😕
@ArvindYADAV-ex4mp2 жыл бұрын
Thanks, Vincent, for this wonderful tutorial but I am curious, can we set the value in private property? I have tried from my side using as a string, I can access the private variable, but I am not able to set any new value to that variable.
@v_pradeilles2 жыл бұрын
Mirror is indeed a read-only API. So the only thing you could do, would be to mutate the state of a reference type property.
@xingzhao24492 жыл бұрын
it can only be used in Class not Struct right?
@v_pradeilles2 жыл бұрын
I think Mirror should behave the same way with a struct.