SwiftUI를 근본부터 다지기 위해 새로운 강의를 들으며 학습하고 있다.
강의의 내용중 기록해놓으면 도움이 될 것 같은 자료들을 정리해보자.
- stored vars
var isFaceUp: Bool
- computed vars
var body: some View {
return Text("Hello World")
}
- constant lets
let defaultColor = Color.orange
- functions
func multiply(_ operand: Int, by: Int)->Int {
return operand * by
}
multyply(5, by: 6)
- initializers
struct RoundedRectangle {
init(cornerRadius: CGFloat) {
// initialize this rectangle withd that corenerRadius
}
init(cornerSize: CGSize) {
// initiralize this rectangle with that cornerSize
}
}
Struct | Class |
---|---|
value type | Reference type |
Copied when passed or assigned | Pass around via pointers |
Copy on write | Automatically reference counted |
Functional programming | Object-oriented programming |
No inheritance | Inheritance |
Mutability must be explicitly stated | Always mutable |