상세 컨텐츠

본문 제목

Day 10. Classes.

TIL/#100DaysOfSwiftUI

by box-jeon 2019. 12. 31. 01:14

본문

https://www.hackingwithswift.com/100/swiftui/10

 

100 Days of SwiftUI – Day 10 – Hacking with Swift

Classes At first, classes seem very similar to structs because we use them to create new data types with properties and methods. However, they introduce a new, important, and complex feature called inheritance – the ability to make one class build on the f

www.hackingwithswift.com

Struct와 Class의 5가지 차이점을 이야기합니다. 

1. struct는 memberwise initializer를 제공하지만, class는 제공하지 않는다.
2. class는 상속이 가능하지만, struct는 불가능하다.
3. struct는 value지만 class는 reference다.
4. class는 deinitializer를 제공하지만, struct는 제공하지 않는다.
5. instance를 let으로 선언한 경우 struct는 property 변경을 할 수 없지만, class는 property를 변경할 수 있다.

그렇군요. Struct는 deinitializer를 제공하지 않는군요.

'TIL > #100DaysOfSwiftUI' 카테고리의 다른 글

Day 12. Optionals.  (0) 2020.01.06
Day11. Protocols and extensions.  (0) 2020.01.01
Day 9. Structs, part two.  (0) 2019.12.29
Day 8. Structs, part one.  (0) 2019.12.28
Day7. Closures, part two.  (0) 2019.12.28

관련글 더보기

댓글 영역