상세 컨텐츠

본문 제목

Day 24. Project 3, part 2

TIL/#100DaysOfSwiftUI

by box-jeon 2020. 3. 9. 23:44

본문

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

 

100 Days of SwiftUI – Day 24 – Hacking with Swift

Project 3, part 2 Albert Einstein once said, “any fool can know; the point is to understand,” and this project was specifically about giving you a deeper understanding of what makes SwiftUI tick. After all, you’ll be spending the next 76 days working with

www.hackingwithswift.com

전날 다룬 내용의 wrap up 입니다. SwiftUI가 어째서 struct를 사용하며, some View가 왜 중요한지 계속 강조합니다. 주어진 문제들을 풀고 실습 과제를 수행합니다. Custom ViewModifier와 Composition View를 project 1, 2에 각각 작업해보는데, 이상한 부분을 또 하나 찾았습니다. Title이라는 Custom ViewModifier를 정의했는데, font()나 foregroundColor() 같은 건 정의가 되는데, fontWeight()는 정의할 수 없었습니다. 아니 그럼 font()나 foregroundColor()는 View가 갖고 있나요? 갖고 있네요. foregroundColor()는 이해가 되는데 font()를 갖고 있는 건 조금 이상하게 느껴집니다.

UIView와 달리 View를 struct로 구현하면 필요한 것만 갖고 있어서 깔끔하다더니, 갖고 있는 게 많네요. @inlinable이 눈길을 끕니다. 처음 봤지만... Swift 4.2에서 추가된 문법이었습니다. 구현체까지도 모듈의 public interface로 만들어준다는 게 무슨 뜻인지 잘 이해가 안가네요.

Inlinable
Apply this attribute to a function, method, computed property, subscript, convenience initializer, or deinitializer declaration to expose that declaration’s implementation as part of the module’s public interface. The compiler is allowed to replace calls to an inlinable symbol with a copy of the symbol’s implementation at the call site.

 

https://github.com/utrpanic/today-what-else/commit/f899daa30bf9aaa8594ae9bb689a07bec668b2ea

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

Day 26. Project 4, part 1  (0) 2020.03.12
Day 25. Milestone: Projects 1-3  (0) 2020.03.11
Day 23. Project 3, part 1  (0) 2020.03.08
Day 22. Project 2, part 3  (0) 2020.03.08
Day 21. Project 2, part 2  (0) 2020.03.07

관련글 더보기

댓글 영역