https://www.hackingwithswift.com/100/swiftui/8
100 Days of SwiftUI – Day 8 – Hacking with Swift
Structs, part one I know some of you might be keen to charge on with today’s new Swift learning, but hold up: you just finished learning about closures, which are a difficult topic. And you came back for more. Seriously, that deserves a lot of respect. And
www.hackingwithswift.com
Java가 주력 언어인 상태에서 Swift를 배운 탓에 뭐든 object reference로 생각하는 게 기본으로 박혀있었던 것 같습니다. 초반에 Array와 Dictionary가 value type인 걸 인지 못해서 실수도 여러 번 했었죠. struct를 사용하면 let/var를 더 명확히 구분해서 사용할 수 있고, 기본생성자도 제공받게 됩니다. Value type이니 functional programming 에도 유용하고, Decodable을 extension으로 구현할 수 있는 것도 이득... 게다가 SwiftUI에서도 struct가 거의 기본인 것처럼 보입니다. 지금부터라도 class로 구현한 모델들을 조금씩 struct로 전환하는 것이 좋을까. Reference type과 Value type을 섞어서 사용했다가 난리가 나는 건 아닐까. SwiftUI의 source of truth를 class로 구현하면 정말 손이 많이 가게 될까. 이런저런 생각할 거리가 많은 것 같습니다.
Day 10. Classes. (0) | 2019.12.31 |
---|---|
Day 9. Structs, part two. (0) | 2019.12.29 |
Day7. Closures, part two. (0) | 2019.12.28 |
Day 6. Closures, part one. (0) | 2019.12.27 |
Day 5. Functions. (0) | 2019.12.26 |
댓글 영역