개발/Swift
-
Label Attribute 이미지 처리, 줄넘김 하기개발/Swift 2024. 9. 12. 13:53
요구사항이미지 + 텍스트 + 이미지 + 텍스트 + 강조텍스트 + 텍스트 형태의 레이아웃 구현이 필요영역을 넘어갈경우 다음줄로 넘어가면 되는데 그런경우 강조텍스트 + 텍스트 이부분이 같이 다음줄로 넘어가야함1줄2. 2줄일 경우 해결 방법이미지와 텍스트를 따로 구현하기에는 줄넘김을 구현하기에 레이아웃 잡기 쉽지 않아보임, 관리할 컴포넌트가 너무많아 비효율적이라 판단 하여 Attribute Text 로 구현텍스트에 이미지 추가하기private func getImageAttributedString(image: UIImage) -> NSAttributedString { let imageAttachment = NSTextAttachment(image: image) imageAttachment.bounds..
-
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] 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] 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..
-
iOS 앱 자동화 Fastlane Fastfile 작성 Cheatsheet개발/Swift 2024. 4. 29. 17:30
프롬프트 활용 input 값 받아 사용하기ex> 출시노트에 사용될 텍스트 or 테스터 이메일 받아오기 title = prompt(text: "출시 노트를 작성해 주세요\\n 개요: ") show_update_popup = prompt(text: "업데이트 팝업 노출 여부: ", boolean: true) description = prompt(text: "변경사항: ", multi_line_end_keyword: "END") testers = prompt(text: "테스터 이메일 입력: ", multi_line_end_keyword: "END")터미널에서 바로 입력하여 값 받아오기 lane :beta_release do |options| version = options[:v..