일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 리팩토링
- UICollectionView
- Human interface guide
- Protocol
- 스위프트
- swiftUI
- 애니메이션
- 리펙토링
- ios
- clean architecture
- ribs
- collectionview
- Refactoring
- uitableview
- 리펙터링
- MVVM
- 클린 코드
- map
- combine
- SWIFT
- HIG
- Observable
- uiscrollview
- tableView
- Clean Code
- rxswift
- Xcode
- swift documentation
- UITextView
- RxCocoa
- Today
- Total
목록Dictionary (6)
김종권의 iOS 앱 개발 알아가기
일반적인 DataSource 관리 Section이 여러개이고 Item도 여러개인 경우, 보통 dataSource를 2차원 배열로 하거나, Section과 Item을 갖는 struct를 만들어서 관리 class ViewController: UIViewController { struct Section { var title: String var items: [String] } var sections: [Section] = [ Section(title: "header is a", items: ["A1", "A2"]), Section(title: "header is b", items: ["B1", "B2"]), ] let tableView: UITableView = {...} } extension ViewCont..
단순 열거 switch 형태 단순히 자연수를 입력하면 한글로 변환시키는 목적이 있을때 아래처럼 사용이 가능 extension Int { var asHangul: String? { switch self { case 1: return "하나" case 2: return "둘" case 3: return "셋" case 4: return "넷" case 5: return "다섯" default: return nil } } } print(1.asHangul) // "하나" 이렇게 사용하게되면 switch, case, return문이 여러개 들어가게 되면서 길어질 수 있기 때문에, dictinoary를 활용하면 조금 더 단순하게 표현이 가능 extension Int { var asHangulV2: String? ..
zip array에서 사용하는 결합 연산자 두 원소가 항상 같이 짝짓는 연산자 var array1 = [1,2,3,4,5] var array2 = ["a", "b", "c", "d", "e"] zip(array1, array2) .forEach { value1, value2 in print(value1, value2) } /* 1 a 2 b 3 c 4 d 5 e */ 만약 둘 중 하나가 없다면 짝짓지 못하므로 값 x var array1 = [1,2,3,4,5] var array2 = ["a"] zip(array1, array2) .forEach { value1, value2 in print(value1, value2) } /* 1 a */ merge, merging dictionary에서 사용하는 병합 ..
allSatisfy 연산자 Collection의 모든 요소가 특정 조건을 만족시키는지 알고 싶은 경우 사용 ex) 배열을 순회하면서 원소들이 특정 조건을 모두 만족하는지 확인할 때 사용 Array, Dictionary, Set 타입에 사용 let arr = ["abcdef", "12345", "문자열"] let bool = arr.allSatisfy { $0.count > 2 } print(bool) // true let dict = ["1": 1, "2": 2] let bool2 = dict.allSatisfy { $0.key == String($0.value) } print(bool2) // true var set = Set() set.insert(2) set.insert(4) set.insert(6..
Swift 컬렉션은 3가지 Array Set Dictionary Array 갯수와 값을 지정한 초기화 let intArr = [Int](repeating: 0, count: 10) 추가: '+=' 연산자 사용 intArr += [2] 삽입: insert(_:at:) 기존에 at에 있던 값은 오른쪽으로 밀려나는 형태 var intArr = [Int](repeating: 0, count: 3) // [0, 0, 0] intArr.insert(2, at: 1) // [0, 2, 0, 0] 삭제: remove(at:) var intArr = [Int](repeating: 0, count: 3) // [0, 0, 0] intArr.insert(2, at: 1) // [0, 2, 0, 0] let removedVa..
알고리즘 핵심: https://ios-development.tistory.com/525 swift로 알고리즘 접근 코드의 간결화를 위해 강제 unwraping 사용 string타입에서 특정 character접근 시 [Charactor] or [String] 타입으로 변환하여 효율적으로 접근 String타입에서 특정 character 접근 시 O(N) Array타입은 random access O(1) String의 for문에서 value값은 String.Element형 :(for문 안에서 Int형으로 변경하고 싶은 경우, String으로 먼저 변형) swift는 Array, Set, Dictionary 세 가지 collection을 제공하므로 나머지 세 가지에 대해 어떻게 쓸것인지 미리 고민 Heap: S..