1

I am using CCBottomRefreshControl frame work for tableview pagination

code: with this code i am able to show only 10 records.. here if i put break point on refresh its not calling.. why? how to refresh tableview after every 10 records

import UIKit
import CCBottomRefreshControl
class SearchResultViewController: UIViewController {

@IBOutlet weak var resultTableView: UITableView!
var currentPageNumberVM: Int = 0
var isLoading = false

public var jobsData : Array<DataUser>?

var searchData = JobSearchResult_Base(dictionary: NSDictionary()) {
    didSet{ }
}
override func viewDidLoad() {
    super.viewDidLoad()
    
    resultTableView.dataSource = self
    resultTableView.delegate = self
    
    let bottomRefreshController = UIRefreshControl()
    bottomRefreshController.triggerVerticalOffset = 1
    bottomRefreshController.addTarget(self, action: #selector(refresh), for: UIControl.Event.valueChanged)
    self.resultTableView.bottomRefreshControl = bottomRefreshController
    self.resultTableView.bottomRefreshControl?.tintColor = .black
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.currentPageNumberVM = 0
    jobSearchResultServiceCall(keyword: "", location: "", pincode: "", job_type: [], experience: [], wage: [], job_role: "", datePosted: [])

}

@objc func refresh() {// is not called
    jobSearchResultServiceCall(keyword: "", location: "", pincode: "", job_type: [], experience: [], wage: [], job_role: "", datePosted: [])
}

func jobSearchResultServiceCall(keyword: String, location: String, pincode: String, job_type: [String], experience: [String], wage: [String], job_role: String, datePosted: [String]) {
 
    let param = [
        "keyword": keyword,
        "job_role": job_role,
        "posted_on": datePosted.map{String($0)}.joined(separator: ","),
        "page" : currentPageNumberVM
    ] as [String : Any]
    print(param)
    
    APIReqeustManager.sharedInstance.serviceCall(param: param, method: .post, url: CommonUrl.job_search_result){ [weak self] (resp) in

        print("count: \(self?.currentPageNumberVM)")
        if (self?.currentPageNumberVM)! > 0 {
                if (JobSearchResult_Base(dictionary: resp.dict as NSDictionary? ?? NSDictionary())?.result?.jobs?.data ?? [DataUser]()).count > 0 {
                    self?.searchData?.result?.jobs?.data! += JobSearchResult_Base(dictionary: resp.dict as NSDictionary? ?? NSDictionary())?.result?.jobs?.data ?? [DataUser]()
                }else {
                }
            }
            else{
                self?.searchData = JobSearchResult_Base(dictionary: resp.dict as NSDictionary? ?? NSDictionary())
            }
            self?.resultTableView.bottomRefreshControl?.endRefreshing()
        self?.isLoading = false
        self?.jobsData = self?.searchData?.result?.jobs?.data
            self?.resultTableView.reloadData()
        self?.currentPageNumberVM += 1

    }
}

0 Answers0