K
K
Kikodo2021-06-29 11:48:17
Swift
Kikodo, 2021-06-29 11:48:17

How to delete cell in tableView using RxSwift?

Hello. Can you please tell me how can I remove the first element in the table when prependButtonAction is pressed.

struct Person {
    let name : String
    let age : Int
    
}

class FiveV2ViewController: UIViewController {
    let personArray = [
        Person(name: "Kirill", age: 17),
        Person(name: "Anton", age: 17)
    ]
    
    let disposeBag = DisposeBag()
    var items : Observable<[Person]>!
    
    @IBOutlet weak var mytable: UITableView!
    override func viewDidLoad() {
        super.viewDidLoad()
        items = Observable.just(personArray)
        bindData()
    }
    
    @IBAction func prependButtonAction(_ sender: UIButton) {
        

        mytable.rx
            .itemDeleted
            
        //
        //......... Вот тут я хочу вызывать удаление 
        //
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Tutubalin, 2021-07-01
@Kikodo

Good afternoon, you need to delete from the data source, that is, in your case from the items array, if the data binding is done correctly, then the table will be updated

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question