[LEVEL 1] 10. Access Control Levels #44
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Swift의 접근 제어자(Access Control Levels)에 대해 설명해주세요.
open
가장 개방적인 접근 제어자.
모듈 외부에서도 접근 가능.
다른 모듈에서 상속, 오버라이드가 가능.
주로 프레임워크 개발 시 사용.
ex)
func viewWillApeear(),viewDidLoad()public
모듈 외부에서 접근 가능.
다른 모듈에서 상속 및 오버라이드 불가능.
라이브러리나 외부에 공개할 API 개발 시 사용.
ex)
func addSubview(),removeFromSuperview()package
internal
fileprivate
private
open과 public의 차이점은 무엇인가요?
override func viewWillAppear(_ animated: Bool)view.addSubview(stackView)internal, fileprivate, private의 사용 시기는 어떻게 결정하나요?
internal
다른 파일에서도 접근이 필요할 때
ex) 모듈 내 다른 파일에서 접근이 가능해야 하는 API 메서드의 경우
func fetchUser()fileprivate
private
접근 제어자를 사용하는 이유는 무엇인가요?
코드 캡슐화를 해야하는 이유