0
private let selectedPhotos = BehaviorRelay<[PHAsset]>(value: [])

private lazy var completeButton = UIBarButtonItem(title: "확인",
                                                      style: .plain,
                                                      target: nil,
                                                      action: nil)

A variable is declared.

private func bind() {
        selectedPhotos.asObservable()
            .map { $0.isEmpty } 
            .bind(to: completeButton.rx.isHidden)
            .disposed(by: disposeBag)
    }

"Cannot assign to property: 'self' is immutable"
I got this error

"completeButton.rx.isHidden" is underlined.

These codes are written in class

Hees
  • 17
  • 4

2 Answers2

-1

as you mentioned

private let selectedPhotos = BehaviorRelay<[PHAsset]>(Value: [])

is declared as a let constant.

Use var instead.

If it's declared inside a viewController (that is a class of course) this way it should become mutable.

  • A BehaviorRelay is a class. You should never use `var` to define one because you don't want to loose all the observers. – Daniel T. Aug 28 '23 at 14:29
-1

I solved it thanks to you. UIBarButtonItem supports isHidden from 16.0. But I am wondering why this error occurs enter image description here

Originally, I know that this error occurs enter image description here

Hees
  • 17
  • 4