clamp
Clamp
clamp
글쓰기 관리
전체 방문자
오늘
어제
  • 분류 전체보기 (509)
    • IOS (85)
    • SwiftUI+TCA+Combine (9)
    • RxSwift + MVVM (56)
    • Clean Architecture (12)
    • SWIFT (56)
    • iOS - TDD (2)
    • 디자인패턴 (4)
    • CS (56)
      • 알고리즘 (29)
      • 운영체제 (15)
      • 자료구조 (2)
      • 네트워킹 (4)
      • 기타 (6)
    • 회고 (0)
    • Firebase (18)
    • SwiftUI (10)
    • iOS - UIKit (11)
    • iOS - 오픈소스 (6)
    • 코딩테스트 (166)
      • 프로그래머스 (164)
    • 정보처리기사 (14)
    • GitHub (2)
글쓰기 / 관리자

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • Swift
  • ㅅ
  • uikit
  • Q

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
clamp

Clamp

IOS

iOS - The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions(Rx 타입추론에러)

2023. 2. 23. 16:01

The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions

 

Rx를 공부하다가 발생한 에러.

 

combineLatest와 map을 사용하다가 발생했다.

타입을 추론하기 어려워 빌드할 수 없다는 내용

 

Observable.combineLatest([redSlider.rx.value, greenSlider.rx.value, blueSlider.rx.value])
            .map{ UIColor(red: CGFloat($0[0]) / 255, green: CGFloat($0[0]) / 255, blue: CGFloat($0[0]) / 255, alpha: 1.0)
            }
            .bind(to: colorView.rx.backgroundColor)
            .disposed(by: bag)

을

Observable.combineLatest([redSlider.rx.value, greenSlider.rx.value, blueSlider.rx.value])
            .map{ source -> UIColor in
              let red = CGFloat(source[0]) / 255
              let green = CGFloat(source[1]) / 255
              let blue = CGFloat(source[2]) / 255
                
                return UIColor(red: red, green: green, blue: blue, alpha: 1.0)
            }
            .bind(to: colorView.rx.backgroundColor)
            .disposed(by: bag)

로 하나하나 잘 쪼개고 리턴타입을 정확히 명시해주니 해결됐다.

저작자표시 비영리 동일조건 (새창열림)
    'IOS' 카테고리의 다른 글
    • iOS. 동시성(Concurrency) 프로그래밍(1) - 동시성프로그래밍이란? feat. 병렬/동시
    • iOS . 오토레이아웃 - Aspect Ratio
    • [iOS] UserDefault를 활용한 저장, struct형태 저장, 구조체 배열 저장, 로드
    • IOS - Xcode 오류 Application tried to present modally a view controller on itself
    clamp
    clamp
    주니어 iOS개발자의 발악!!!!!!!

    티스토리툴바