Вызывается несколько раз метод из ячейки


#1

Здравствуйте!
У меняя есть таблица с ячейками, в ячейках есть кнопка, событие кнопки формируется в TableViewCell и вызывается как config в cellForRowAt, когда нажимаю на кнопку, там у меня запрос, он вызывается два раза.
из модели:
numberOfRowsInSection = 2
numberOfSections() = 2

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return viewModel.numberOfRow(in: section)
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return viewModel.numberOfSections()
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        switch FriendsScreenSection(rawValue: indexPath.row)! {
        case .friend:
            let cell = tableView.dequeueReusableCell(withIdentifier: FriendCell.cellIdentifier, for: indexPath) as! FriendCell
                cell.config(at: index, with: viewModel.getAcceptedFriendsPreview(at: index), viewModel: viewModel)
            return cell
        case .loadMore:
            let cell = tableView.dequeueReusableCell(withIdentifier: FriendLoadMoreCell.cellIdentifier, for: indexPath) as! FriendLoadMoreCell
            return cell
        }
    }


   func numberOfSections() -> Int {
        return FriendsScreenSection.allCases.count
    }
    
    func numberOfRow(in section: Int) -> Int {
        switch FriendsScreenSection(rawValue: section)! {
        case .friend:
            return acceptedFriendsPreview.count
        case .loadMore:
            return self.isLoadMore ? 1 : 0
        }
    }


enum FriendsScreenSection: Int, CaseIterable {
case friend
case loadMore
}

Подскажите как это исправить?


#2

А где сама ячейка. В вашем коде нажатия на кнопку нет.


#3

на самом деле проблема была в нескольких подписок в rx событиях, уже разобрался