Section13. 145) Protocol
17분 12초
Protocol
class Bird ->Eagles :CanFly
->Penguins
struct Airplane :CanFly
Protocol: 마치 자격증과 같은거.
Bird - layEggs(), .... 안에 함수가 여러개 있으나 이걸 Penguins이 그대로 상속받을 경우 날지 못하는데 fly함수까지 받아버리므로...
이런 경우 penguins 의 기능에 해당하는 함수들을 Bird안에 구현해서
CanFly는 따로 프로토콜로 채택해주는 식으로.
'iOS > iOS Swift Udemy - AngelaYu' 카테고리의 다른 글
Sec13 152) 함수 리팩토링 (computed property) (0) | 2023.01.01 |
---|---|
Sec13 149) Networking - URL Session (0) | 2022.12.27 |
Section13 144) UITextField keyboard "go"클릭시 실행 (0) | 2022.12.13 |
Section13. 143) 다크모드 및 벡터 Assets 작업. (0) | 2022.12.13 |
Section19 247) searchbar에서 검색 취소 클릭시 키보드 내리기 (0) | 2022.11.01 |