| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
- CoreLocation
- UICollectionViewFlowLayout
- Required Reason API
- 러닝타이머
- WeatherManager
- UIAlertAction
- 한국어 개인정보처리방침
- weatherKit
- 서체관리자
- Protocol
- addannotation
- MKMapItem
- AnyObject
- 단일 책임원칙
- 러닝기록앱
- RunningTimer
- dispatchsource
- App Store Connect
- MKMapViewDelegate
- 영문 개인정보처리방침
- swift
- CLLocationManagerDelegate
- Timer
- 클로저의 캡슐화
- weak var
- font book
- xcode로 날씨앱 만들기
- SwiftUI Boolean 값
- Xcode
- Startign Assignments
- Today
- Total
VesselWheel
변수 간 연결(Value binding pattern) 본문
import UIKit
/*
Value Binding Pattern
case let 변수:
case var 변수:
*/
let number = 10
/*
case let num: 에서 num이라는 변수가
메모리에 로딩되고 switch number 에 있는
number 가 let num 에 할당됨(binding:복사됨)
binding 된 상수(let num)는 case 블럭 안에서만 사용할 수 있음
*/
switch number{
case let num:
print("num :",num)
}
// binding 된 상수(let num)는 case 블럭 안에서만 사용할 수 있음
// print("num :",num)
switch number{
case let num where num > 100:
print("num :",num)
default:
print("num은 100 보다 크지 않음")
break
}
let number2 = 222
switch number2{
case var num where num > 100:
num = 333
print("num :",num)
default:
print("num은 100 보다 크지 않음")
break
}
let tuple1 = (11, 22, 33)
switch tuple1{
case let (x, y, z):
print(x, y, z)
}
switch tuple1{
case (let x, let y, let z):
print(x, y, z)
}
switch tuple1{
case (let x, var y, var z):
print(x, y, z)
}
switch tuple1{
// _ : wildcard 패턴 <- y 는 사용하지 않는 경우
case let(x, _, z):
print(x, z)
}
'Xcode Study' 카테고리의 다른 글
| 반복문 for 변수 in 범...위{} (0) | 2023.05.02 |
|---|---|
| Pattern Matching 연산자 overloading (0) | 2023.05.02 |
| Guard 문의 개념 (0) | 2023.04.30 |
| [SwiftUI] Allow Arbitrary Loads, 외부 URL 허용 (0) | 2023.04.29 |
| [SwiftUI] webview 사용 코드 (0) | 2023.04.29 |