일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
- addannotation
- AnyObject
- font book
- App Store Connect
- WeatherManager
- swift
- 러닝기록앱
- MKMapItem
- weatherKit
- UICollectionViewFlowLayout
- SwiftUI Boolean 값
- dispatchsource
- weak var
- Timer
- CoreLocation
- 서체관리자
- UIAlertAction
- Protocol
- MKMapViewDelegate
- 러닝타이머
- xcode로 날씨앱 만들기
- Required Reason API
- 한국어 개인정보처리방침
- 클로저의 캡슐화
- Startign Assignments
- CLLocationManagerDelegate
- 단일 책임원칙
- RunningTimer
- 영문 개인정보처리방침
- Xcode
- Today
- Total
VesselWheel
Tuple 본문
import UIKit
/*
튜플: Tuple
간단하게 사용하고 버리는 용도
형식 : () 사용 - (값1, 값2, 값3, 값4, 값5, ...)
(이름1:값1, 이름2:값2, 이름3:값3)
함수에서 여러 개의 값을 한꺼번에 return 하는 경우
ㄴ 여러 개의 값을 tuple 에 저장해서 반환함
*/
var tp1 = ("이율곡", 18, 178.7)
print(tp1.0)
print(tp1.1)
print(tp1.2)
// unpacking
var (name, age, height) = ("이율곡", 18, 178.7)
(name, age, height) = tp1
print("name : \(name)")
print("age : \(age)")
print("height : \(height)")
let tp2 = (name:"류성룡", age:32, weight:72)
print(tp2.name)
print(tp2.age)
print(tp2.weight)
// 함수의 return 값을 tuple 로 지정해서
// 여러 개 값 return 하기
// <- 여러 개의 값을 tuple 하나에 담아서 return함
func test1() -> (String, Int, Float){
return ("김유신", 23, 190.2)
}
let resultTuple = test1()
print(resultTuple.0)
print(resultTuple.1)
print(resultTuple.2)
// Type Alias(tuple 의 type 을 지정함)
typealias TupleType = (String, Int, Float)
let tp3: TupleType = ("이준", 184, 78)
print(tp3.0)
print(tp3.1)
print(tp3.2)
'Xcode Study' 카테고리의 다른 글
구조체, 열거형, 클래스의 차이 (0) | 2023.10.19 |
---|---|
열거형 : Enum(Enumeration) (0) | 2023.10.19 |
구조체 배열 (0) | 2023.10.19 |
클로져의 변형 (0) | 2023.10.19 |
클로저(Closure): Code Block (0) | 2023.10.19 |