μΌ | μ | ν | μ | λͺ© | κΈ | ν |
---|---|---|---|---|---|---|
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 |
- nodejs
- ios
- CRUD
- mongoose
- Filter
- Decodable
- μ±λμμΈ
- map
- Encodable
- String.Index
- Core Data
- AVAudioPlayer
- Firestore
- RxSwift
- Codable
- ExpressJS
- Reduce
- μκ³ λ¦¬μ¦
- components
- Cloud Firestore
- μ±λ§λ€κΈ°
- μ§λ²λ³ν
- Mac
- Firestore CRUD
- DispatchQueue
- Figma
- νλ‘κ·Έλλ¨Έμ€
- UIRefreshController
- MongoDB
- SWiFT
- Today
- Total
Focus On Develop π€π€
[Swift] enumerated() λ³Έλ¬Έ
μμΈ λ΄μ© : enumerated() | Apple Document
λ μμ΄λ€.. π μνΌ μ΄λ μμ λ°°μ΄ννμ Sequence λ°μ΄ν°λ₯Ό νμν λ κ° λ°μ΄ν°λ§λ€ (n, x) ννμ ννμ 리ν΄νλλ°, μ¬κΈ°μ nμ μΈλ±μ€, xλ ν΄λΉλλ μμμ κ°μ λνλΈλ€.
μλ₯Ό λ€μ΄μ λ€λ₯Έ Languageμμ μλμ²λΌ forλ¬Έμ ν΅ν΄ λ°°μ΄μ μννλλ°, (C++ λ무 μ€λλ§μ΄λΌ λ¬Έλ²λ λͺ¨λ₯΄κ² λ€ γ γ ; π©)
for (int i=0; i<array.size(); i++) {
cout << i << "= " << array[i] << endl;
}
Swiftμμλ μΈλ±μ€ λ²μμ ν¬κ² μ κ²½μ°μ§ μμλ λλ, λ°λ‘ λ°°μ΄μ μμκ°μ μ κ·Ό κ°λ₯νλλ‘ forλ¬Έμ ν΅ν κ°λ ₯ν Sequence νμκΈ°λ₯μ μ 곡νλ€. μνΌ.. enumeratedλ μλμ²λΌ μμ½κ² Sequenceλ₯Ό νμν μ μκ² λμμ£Όλ μΉκ΅¬λ€ ππ μ μ©ν©μλ€!
let array: [String] = ["my", "name", "is", "kt"]
for (n, x) in array.enumerated() {
print("\(n) = \(x)")
}
/*
0 = my
1 = name
2 = is
3 = kt
*/
let array2: [Int] = [11, 22, 33, 44, 55]
for (n, x) in array2.enumerated() {
print("\(n) = \(x)")
}
/*
0 = 11
1 = 22
2 = 33
3 = 44
4 = 55
*/
'iOS [Swift] > κΈ°μ΄λ₯Ό ννν!' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Swift] String.components (0) | 2020.12.18 |
---|---|
[Swift] String.Index (0) | 2020.12.17 |
[Swift] String Radixλ₯Ό ν΅ν μ§λ²λ³ν (0) | 2020.12.16 |
[Swift] Set (0) | 2020.12.15 |
[Swift] map, filter, reduce (0) | 2020.12.15 |