1. 구조체
- 스위프트 대부분 타입은 구조체로 형성
- 구조체는 값 타입
- 상속 불가
- 인스턴스 / 타입 메서드
- 인스턴스 / 타입 프로퍼티
- 값 타입
struct StructName {
}
2. Property / Method 구현
struct SampleStruct {
var mutableProperty: Int = 100
let immutableProperty: Int = 100
static var typeProperty: Int = 100
func instanceMethod() {
print("instance")
}
func typeMethod(){
prict("type")
}
}
var mutable: SampleStuct = SampleStruct()
mutable.mutableProperty = 200
mutable.immutableProperty = 200
let immutable: SampleStruct = SampleStruct()
immutabl.immutableProperty = 200
SampleStruct.typeProperty = 300
SampleStruct.typeMethod()
mutable.typeProperty = 400
mutable.typeMethod()