iOS

    [Combine] Chapter 16: Error Handling

    이번 챕터에서는 에러 핸들링에 대해 알아보겠습니다. 비동기 이벤트를 다룰 때 에러가 항상 발생할 수 있습니다. 그래서 에러를 다루는 기술을 굉장히 중요합니다. Publisher Failure 이 친구에 집중해봅시다. Never publisher가 fail 이벤트가 절대 일어나지 않는 경우 사용합니다. 예를들어 Just를 확인해보면 Failure가 Never로 정의된 것을 볼 수 있습니다. setFailureType infallilbe publisher 를 만드는 방법! assign(to:on:) assign 이 걸려있는 곳에서 setFailureType을 하려고 하면 컴파일이 되지 않습니다. Failure가 Never 일때만 assign이 가능한것으로 보입니다. assertNoFailure 에러가 발생헀..

    워닝 제거하기: ld: warning: method '{methodName}' in category from {file build path}.o conflicts with same method from another category

    이번에도 워닝 제거하기 시리즈인데요. 이런 에러를 만났습니다. ld: warning: method '{methodName}' in category from {file build path}.o conflicts with same method from another category objective-c에서 카테고리를 통해 method를 확장한 케이스 입니다. 두개의 카테고리에서 동일한 이름을 쓰는 method를 발견할 수 있었습니다. 조금 이상한 것은 다른 클래스명을 가지고 있었는데도 워닝이 뜨고 있는 점 입니다. 알고보니 해당 method는 팩토리 메소드로 사용하고 있었고 카테고리를 구현하는 .m 파일 안에서 중복된 2개의 구현부가 있었습니다. 예를 들어보면 이런식 입니다. // MyClass+Catego..

    워닝 제거하기: Skipping duplicate build file in Compile Sources build phase

    이번에는 이런 워닝을 들고 왔습니다. 이건 뭘까요? 그냥 파일명으로 검색해보면 하나 밖에 없습니다. 중복되는 파일은 없는데요. sarunw.com/posts/how-to-fix-duplicate-references-warning/ How to fix "Skipping duplicate build file" warning in Xcode | Sarunw There might be several reasons that cause this error. Here are the solutions that fix it for me. sarunw.com 프로젝트 > Build Phases 로 들어가서 검색해보니 Compile Sources에 파일이 두개 등장합니다. 과감히 삭제해버립니다. 근데 그러고 빌드하면 파일을..

    워닝 제거하기: Implicit import of bridging header '{YourApp}-Bridging-Header.h' via module '{YourApp}' is deprecated and will be removed in a later version of Swift

    안녕하세요 코찐입니다. 오늘은 다음과 같은 에러를 만나서 해결하는 과정을 기록해봅니다. Implicit import of bridging header '{AppName}-Bridging-Header.h' via module '{AppName}' is deprecated and will be removed in a later version of Swift 원래는 Briding-Header 를 암시적으로 import 해주고 있었는데, 이제는 자동적으로 브릿징 헤더를 import 해주지 않겠다는 워닝입니다. 워닝이 뜨는 테스트 파일이 있고, 안뜨는 테스트 파일도 있습니다. 1. 언제 워닝이 발생할까? 그럼 이번 테스트 파일에서는 왜 워닝으로 저 내용을 알려줄까요? 알고보면 현재 테스트 내용에서 objcecti..

    [iOS] grouped style tableView에서 위아래 여백 제거하기

    UITableView(frame: .zero, style: .grouped)로 사용하는데 상하단의 여백을 없애고 싶을 때가 있습니다. 이 글에서는 하단의 여백을 없애는 것으로 예를 들어보겠습니다. 두가지를 지정해주면 됩니다. 1. header or footer height를 최소로 지정 func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { UIView() } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { .leastNormalMagnitude } 2. content inset 없..

    [Combine 책 정리] Chapter 13: Resource Management

    안녕하세요 코찐입니다. 아래의 자료를 따라서 공부하고 있습니다. https://www.raywenderlich.com/books/combine-asynchronous-programming-with-swift/v2.0 리소스 관리하는 Publisher 들인데, API 작업할 때 유용하게 사용할 수 있습니다. share value 타입이 아닌 reference 타입의 publisher를 공유할 수 있도록 해줍니다. 주의할 점은 이미 complete 된 share publisher를 구독하면 complete만 받게 됩니다. let shared = URLSession.shared .dataTaskPublisher(for: URL(string: "https://www.raywenderlich.com")!) .ma..

    [Combine 책 정리] Chapter 12: Key-Value Observing

    안녕하세요 코찐입니다. 아래의 자료를 따라서 공부하고 있습니다. https://www.raywenderlich.com/books/combine-asynchronous-programming-with-swift/v2.0 KVO 그 유명한 KVO 입니다. OperationQueue의 operation 개수가 변경되면 sink에서 이벤트를 받아볼 수 있습니다. let queue = OperationQueue() let subscription = queue.publisher(for: \.operationCount) .sink { print("Outstanding operations in queue: \($0)") } 커스텀으로 만들려면? 1. NSObject 상속 2. @objc dynamic 키워드 KVO가 O..

    [Combine 책 정리] Chapter 11: Timers

    안녕하세요 코찐입니다. 아래의 자료를 따라서 공부하고 있습니다. https://www.raywenderlich.com/books/combine-asynchronous-programming-with-swift/v2.0 타이머 클래스에는 삼형제가 있습니다. RunLoop, Timer, DispatchQueue RunLoop 특정 RunLoop 상에서 이벤트를 발생시킬 수 있습니다. 1초마다 한번씩 print 합니다. let runLoop = RunLoop.main runLoop.schedule( after: runLoop.now, interval: .seconds(1), tolerance: .milliseconds(100) ) { print("Timer fired") }.store(in: &subscript..