Skip to content

프로토콜이란 무엇인지 설명하시오. #29

Description

@Glsme

Protocol

특정 메서드나 프로퍼티 및 기타 요구 사항의 청사진(Bluprint)을 의미한다.

  • 클래스의 단점을 보완한다.
Class Protocol
하나의 클래스만 상속 가능 다중 상속 가능
클래스 타입에서만 가능 모든 타입 적용 가능

정의 방법

protocol Student {
    var id: String { get }
    var name: String { get set }
    func study()
}
  • Protocol은 타입이다. 따라서 Protocol을 변수에 할당할 수 있고, 함수 호출 시 파라미터로 전달할 수 있으며, 함수에서 Protocol을 반환할 수 있다.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions