[iOS] Structure와 Class의 차이

HL·2022년 5월 5일
0

iOS

목록 보기
16/22

Value Type vs Reference Type

  • struct, enum은 value 타입
  • class는 reference 타입

클래스의 추가 기능

  • Inheritance enables one class to inherit the characteristics of another.
  • Type casting enables you to check and interpret the type of a class instance at runtime.
  • Deinitializers enable an instance of a class to free up any resources it has assigned.
  • Reference counting allows more than one reference to a class instance.
  • 상속
  • 타입캐스팅
  • 해제
  • RC

언제 쓰면 좋은지

  • struct를 선호
  • 필요할때만 class 사용

링크

https://docs.swift.org/swift-book/LanguageGuide/ClassesAndStructures.html
https://developer.apple.com/documentation/swift/choosing_between_structures_and_classes

profile
Frontend 개발자입니다.

0개의 댓글