One of the reasons I purchased your “iOS Dev Job Interview practice” without even thinking, is your crystal clear way to explain things! Keep it up Sean!
Apple, please fix the "private" access control to also work in extensions that are in other files, not only in the same file with the declaration. 🤷♂️ Great video!
File= viewcontroller.swift. You can have many classes under a file like (class view, class Student etc.) fileprivate lets you use a method or a variable inside these classes because they are in the same file(viewcontroller.swift) , but private is private in a class! So you cant call the method that you build inside student class into view class because classes can’t see other classes private methods until you initialize it
Hi Jasur. "final" is not an Access Control Specifier, it's a Declaration Modifier. It’s applied to a class to indicate that the class can’t be subclassed. It’s applied to a property, method, or subscript of a class to indicate that a class member can’t be overridden in any subclass. Source: docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID381 Hope it helps :)
Public is exposed to outside projects. For example if you were to import a 3rd party library or SDK, they would need to mark their functions as public so your project would have access to them. Internal is exposed to everything within that specific project.
can u pls do more iOS interview questions? I ran through that playlist and the Swift Keywords playlist and need more of ur content bc this really sticks with ur explanations !! Thanks!!!
Cool video, as always! As you said, it covers the basics more than enough. One little nitpicky thing: I'm sad you didn't include "private(set)" - although I guess it's not a core part of access control, IMO it's a super useful feature! (commenting mostly so that the few people who read comments might hear about it for the first time 😀 don't know if you omitted it on purpose)
Thanks JK Kross! I did omit that kind of stuff on purpose because I wanted to keep the video focused on the core principle of Access Control. I imagine this video will mostly help beginners and Jr. devs. That's the tough thing about creating tutorials. It's tough to not discuss all the tangential topics, but I don't want to make the video lose focus, drag on forever, or be too overwhelming for viewers.
@@seanallen totally understandable! 😎 I'm just that kind of person who loves being bombarded by information 😂😂😂 But I think your reasoning is valid - I watched a few "overwhelming" videos when I was a total noob and it certainly did not help 😂 Only recently I watched some of them again and finally understood 😀
Really wish Xcode let you set access control in bulk or something. I mostly develop packages & marking relevant variables, methods, and structures public or open can be really clumsy and error prone. There’s also really silly things like struct’s memberwise initializer is specifically marked internal. So I can’t remember a time where I wrote a package, added it to a project and created my own initializer and properly marked it public. Really frustrating!
Hi Sean, great video but it would have been awesome if at the end you have mentioned that you can give specific access control for property setters like for example 'private(set) var isOn' . But its fine, anyone can read it in the link you gave :)
Glad you liked that video, Stoqn. I omit that kind of stuff on purpose because I wanted to keep the video focused on the core principle of Access Control. I imagine this video will mostly help beginners and Jr. devs. That's the tough thing about creating tutorials. It's tough to not discuss all the tangential topics, but I don't want to make the video lose focus, drag on forever, or be too overwhelming for viewers.
Sean Allen yes Sean you are absolutely right, i bet there are thousand more details that people can point out, but what is the purpose of getting beginners lost in all that ? And after all the more your videos are targeted to a broader audience the better the growth of your channel will be 🙂 Before a couple of moths i tried the exact opposite - a channel showing a really technical stuff and got no views at all ua-cam.com/video/atpB_MaAGFk/v-deo.html So keep up the good work mate, i would say you are doing the best job keeping the ios devs up to date on youtube :) Wish you all best, Stoyan from Bulgaria
Excellent tutorial! very clear explanation, thanks! Also, totally unrelated question but what software do you use to create these videos to essentially have Xcode UI & yourself on the same screen?
Glad you liked it. I'm recording myself with a Canon M3 camera, recording my screen with QuickTime, and recording my audio with a Blue Yet microphone. Then I edit that all together in Final Cut Pro. You can see more about my setup at seanallen.co/store.
Not that much of a performance boost, but you certainly will help the compiler out if you use private wherever it's appropriate. For example in SwiftUI you should always set your @State vars private.
Bit of a nitpick, but early on you keep saying you don't want files outside of the example file to have access to the private property. I think you mean other classes, or even better, outside code.
Watch Next - iOS Take Home Project - Job Interview Practice - Free Preview - ua-cam.com/video/MSIe2y6Fee8/v-deo.html
One of the reasons I purchased your “iOS Dev Job Interview practice” without even thinking, is your crystal clear way to explain things! Keep it up Sean!
Thanks for the kind words, Christos. Hope you enjoy the course 😀
I had some doubts after reading the swift documentation, but you just cleared them out for me. Thank you again!
private(set) is kinda cool too. Gives you read only access, but is private for setters
very important topic i got asked about this topic in my last interview, thank you sean
Thanks for the attention to this, go this in an interview asked.
Hey look, you hit 50k subs - congrats! 🥳
Thanks Jason!
Good thing that Sean has left the subscribers count on "open" so we can follow along. Congrats 🎉
Thanks!
Apple, please fix the "private" access control to also work in extensions that are in other files, not only in the same file with the declaration. 🤷♂️
Great video!
That would be cool... I'm pretty sure after the back and forth with Access Control that happened form Swift 2 to 4, they've put this topic to bed.
no way, thats going to lead to your code-base being a complete mess!
Yixe Why?
It’s pretty common when writting ObjC to move categories into separate files than the parent class.
Thanks Sean. I did not understand fileprivate.
Love your videos, good work
Greetings from Argentina
Happy you liked the video!
File= viewcontroller.swift. You can have many classes under a file like (class view, class Student etc.) fileprivate lets you use a method or a variable inside these classes because they are in the same file(viewcontroller.swift) , but private is private in a class! So you cant call the method that you build inside student class into view class because classes can’t see other classes private methods until you initialize it
This is the video that i was looking for. Thank you Sean.
Glad you got value out of it 😀
Thank you Sean for great tutorial about Access Control. As an addition I would also like to know about "final", where and why to use.
I'm creating a playlist for a lot of the keywords in Swift. "Final" is on my list. You'll see that eventually.
Hi Jasur. "final" is not an Access Control Specifier, it's a Declaration Modifier. It’s applied to a class to indicate that the class can’t be subclassed. It’s applied to a property, method, or subscript of a class to indicate that a class member can’t be overridden in any subclass. Source: docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID381 Hope it helps :)
congrats on 50k subscribers Sean.
Thanks 😀
We need a `groupprivate` I think! Makes it private to a folder/group, similar to Java’s default access modifier.
Excellent tutorial! very clear explanation, thanks!
So whats difference between Public and Internal?
Public is exposed to outside projects. For example if you were to import a 3rd party library or SDK, they would need to mark their functions as public so your project would have access to them. Internal is exposed to everything within that specific project.
can u pls do more iOS interview questions? I ran through that playlist and the Swift Keywords playlist and need more of ur content bc this really sticks with ur explanations !! Thanks!!!
Thanks a lot.
This video is really helpful and easy to understand. 👍👍👍
Great video Sean, thanks a bunch! Always drill the basics, right 👍
Thanks Kevin. Glad you liked it!
Online tutorials should use and teach access control more often. Part of proper coding imho... thanks for the video!
Glad you liked it, Gakkie!
Agreed. For example not many know that in SwiftUI you should always set your @State variables to be private
Hi Allen...
I am requesting
Please upload setters and getters in swift
please do this video Allen
Cool video, as always! As you said, it covers the basics more than enough.
One little nitpicky thing: I'm sad you didn't include "private(set)" - although I guess it's not a core part of access control, IMO it's a super useful feature!
(commenting mostly so that the few people who read comments might hear about it for the first time 😀 don't know if you omitted it on purpose)
Thanks JK Kross! I did omit that kind of stuff on purpose because I wanted to keep the video focused on the core principle of Access Control. I imagine this video will mostly help beginners and Jr. devs. That's the tough thing about creating tutorials. It's tough to not discuss all the tangential topics, but I don't want to make the video lose focus, drag on forever, or be too overwhelming for viewers.
@@seanallen totally understandable! 😎
I'm just that kind of person who loves being bombarded by information 😂😂😂
But I think your reasoning is valid - I watched a few "overwhelming" videos when I was a total noob and it certainly did not help 😂 Only recently I watched some of them again and finally understood 😀
Agreed. It's tough to make a video that will fit thousands of different people's learning style and preference. I do my best to find a middle ground.
Thanks for clear explanation 👍🏻
Glad you liked it!
Really wish Xcode let you set access control in bulk or something. I mostly develop packages & marking relevant variables, methods, and structures public or open can be really clumsy and error prone. There’s also really silly things like struct’s memberwise initializer is specifically marked internal. So I can’t remember a time where I wrote a package, added it to a project and created my own initializer and properly marked it public. Really frustrating!
Hi Sean, great video but it would have been awesome if at the end you have mentioned that you can give specific access control for property setters like for example 'private(set) var isOn' . But its fine, anyone can read it in the link you gave :)
Glad you liked that video, Stoqn. I omit that kind of stuff on purpose because I wanted to keep the video focused on the core principle of Access Control. I imagine this video will mostly help beginners and Jr. devs. That's the tough thing about creating tutorials. It's tough to not discuss all the tangential topics, but I don't want to make the video lose focus, drag on forever, or be too overwhelming for viewers.
Sean Allen yes Sean you are absolutely right, i bet there are thousand more details that people can point out, but what is the purpose of getting beginners lost in all that ? And after all the more your videos are targeted to a broader audience the better the growth of your channel will be 🙂 Before a couple of moths i tried the exact opposite - a channel showing a really technical stuff and got no views at all ua-cam.com/video/atpB_MaAGFk/v-deo.html
So keep up the good work mate, i would say you are doing the best job keeping the ios devs up to date on youtube :)
Wish you all best,
Stoyan from Bulgaria
Thanks for the kind words!
do you have a tutorial on how to read a file in ios development?
Is this encapsulation?
love it! thanks sean!!
Happy to help!
Excellent tutorial! very clear explanation, thanks! Also, totally unrelated question but what software do you use to create these videos to essentially have Xcode UI & yourself on the same screen?
Glad you liked it. I'm recording myself with a Canon M3 camera, recording my screen with QuickTime, and recording my audio with a Blue Yet microphone. Then I edit that all together in Final Cut Pro. You can see more about my setup at seanallen.co/store.
Thank you. Can you make one video on subscript?
Eventually.
Is there an advantage to using private? Is performance affected by degree of access of your code components?
Not that much of a performance boost, but you certainly will help the compiler out if you use private wherever it's appropriate. For example in SwiftUI you should always set your @State vars private.
Thank you so much
Thanks Alot!
No problem!
I really wish they’d put a ‘friend’ accessor in Swift, like C++ has!
YES
Glad you liked it!
it seems that Sean was conflating private and fileprivate for the first 4 minutes
Bit of a nitpick, but early on you keep saying you don't want files outside of the example file to have access to the private property. I think you mean other classes, or even better, outside code.