분류 전체보기
-
Contact Framework 사용하여 연락처 불러오기개발/Swift 2024. 9. 3. 15:05
연락처를 불러 오기 위해서는 연락처 권한이 필수임CNContactStore().requestAccess(for: .contacts) { isGranted, _ in}연락처 권한 허용 여부는 이후로 이렇게 확인 가능CNContactStore.authorizationStatus(for: .contacts) == .authorized권한 허용 이후에는 contact 를 통해 연락처에 접근 가능함static private func getNewContacts() async -> [String: String] { let contactStore = CNContactStore() guard (try? await contactStore.requestAccess(for: .contacts)) ==..
-
Compositional Layout+ Diffable Datasource 활용 가이드개발/Swift 2024. 8. 27. 18:33
Section 영역 은 3가지 타입이며enum 내부에서 각각 레이아웃을 들고 있도록 하여 viewcontroller의 복잡도를 낮추었다.public enum FAQSection: Hashable { case tag case faq case bottomGuide public var layoutSize: NSCollectionLayoutSection { switch self { case .tag: let itemSize = NSCollectionLayoutSize(widthDimension: .estimated(50), heightDimension: .a..
-
[Error] Diffable Datasource 사용중 겪은 여러 에러 해결카테고리 없음 2024. 8. 26. 18:02
does not conform to protocol 'Equatable'Diffable Datasource의 section 과 item 을 구성 하려면 Hashable 준수를 해야하는데Associated Value Enum의 경우 Hashable를 준수 하지 않음 따로 넣어줘야함 근데 전달 하고자 하는 값ex> tag item, faq item이 struct 형태가 아니라 protocol 을 사용하여 넘겨주고 있음 여기서 에러 발생protocol 이 Hashable를 준수 했음에도 에러는 여전히 발생함public enum FAQSectionItem: Hashable { case tag(tag: any FAQTagDisplayable, isSelected: Bool) case faq(item..
-
[Error] suspend resume partial function for XXX개발/Swift 2024. 8. 20. 14:39
“suspend resume partial function for 함수명”라는 에러 발생 원인 파악 public func isFeatureEnabled(_ featureToggle: FeatureToggles) -> Bool { return featureToggles[featureToggle.value.key] }let keyword is a constant and, therefore, read-only and thread-safe. When a variable is declared as var it becomes mutable and not thread-safe unless the data type is specifically designed to be thread-sa..
-
[Error] 당신의 커스텀 UIControl 이 동작하지 않는 이유카테고리 없음 2024. 8. 20. 12:14
보통 버튼이 아니라 UIControl 를 사용하는 이유는 내부 구성 UI 들이 다양한 경우 버튼대신 사용함 UIControl 안에 imageView + containerView로 구성되어있는데 터치가 imageView에만 먹고 containerView 쪽 터치 하면 동작 안함 원인 UIControl 하위 UIView가 있는경우터치를 흡수 하기 떄문에 View 영역 터치하면의도한대로 UIControl 의 터치가 동작 하지 않음 해결view.isUserInteractionEnabled = false stackview를 내부적으로 사용해도 마찬가지임 해당 하는 설정을 넣어줘야 컨트롤이 터치 이벤트를 방출함
-
[Error] navigationbar subview 레이아웃 에러개발/Swift 2024. 8. 20. 12:09
A multiplier of 0 or a nil second item together with a location for the first attribute creates an illegal constraint of a location equal to a constant. Location attributes must be specified in pairs라는 에러가 발생해당 에러는 레이아웃을 잡을떄 second view 가 없거나 할떄 일어나는 문제상황레이아웃 부분showMapToolTip.snp.makeConstraints { make in make.top.equalTo(30) make.trailing.equalTo(-12)}해당 view는 네비게이션 바 에 추가된 view이다view가 아니..
-
[Swift] CoreData 사용해보기: CRUD 구현 가이드개발/Swift 2024. 5. 18. 13:50
문제- API 네트워킹시 네트워크 문제가 있을경우 내부저장 데이터를 리턴해주는 로직 필요.- CoreData는 내부데이터 이므로 Repository 에서 접근 하는게 맞다고 판단 했다.근데 CoreData는 Appdelegate의 persistentContainer.viewContext 에 접근 해야함Repository -> CoreData -> Appdelegate이는 클린 아키텍쳐 구성상 의존성의 방향이 잘못되었다 생각 해결- CoreData 를 사용해서 데이터를 저장 & 사용- Repository 생성시 viewContext를 주입받아 사용Coordinator 패턴이나 의존성 주입 하는 부분에서 해주면 좋을것 같다. let appDelegate = UIApplication.shared...
-
[Swift] Tab bar 와 Page view를 동시에 사용할때개발/Swift 2024. 5. 18. 13:40
문제Tab bar 와 UIPageViewController스와이핑이 가능하면서 동시에 탭바 선택으로 ViewController를 움직이고 싶을때TabbarController 와 UIPageViewController 동시에 사용 할 경우 생각보다 예시가 많이 없고 정상 동작 하지 않았다.TabbarController 는 또한 UI 커스텀이 쉽지 않았다. 해결UIPageViewController 를 사용하여 페이지 관리 를 하고 ( 스와이프 가능 )Tab Bar UI는 직접 커스텀하게 구현 구현- TabBar 에서는 Rx 사용하여 클릭 이벤트 전달함 UIPageViewController 설정private lazy var pageViewController = { let pageViewController..