skip to Main Content
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

2

Answers


  1. Chosen as BEST ANSWER

    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


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search